Skip to content

Commit

Permalink
Register index update listener (#11317)
Browse files Browse the repository at this point in the history
* Register IndexUpdateListener to db

* Fix lucene index path in case opened two libraries with the same name

* Update CHANGELOG.md
  • Loading branch information
LoayGhreeb authored May 23, 2024
1 parent cc464e8 commit fcd6b9b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where imports to a custom group would only work for the first entry [#11085](https://github.com/JabRef/jabref/issues/11085), [#11269](https://github.com/JabRef/jabref/issues/11269)
- We fixed an issue where a new entry was not added to the selected group [#8933](https://github.com/JabRef/jabref/issues/8933)
- We fixed an issue where the horizontal position of the Entry Preview inside the entry editor was not remembered across restarts [#11281](https://github.com/JabRef/jabref/issues/11281)
- We fixed an issue where the search index was not updated after linking PDF files. [#11317](https://github.com/JabRef/jabref/pull/11317)
- We fixed an issue where the entry editor context menu was not shown correctly when JabRef is opened on a second, extended screen [#11323](https://github.com/JabRef/jabref/issues/11323), [#11174](https://github.com/JabRef/jabref/issues/11174)

### Removed
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) {
setupMainPanel();
setupAutoCompletion();

this.getDatabase().registerListener(new IndexUpdateListener());
this.getDatabase().registerListener(new EntriesRemovedListener());

// ensure that at each addition of a new entry, the entry is added to the groups interface
Expand Down Expand Up @@ -1085,9 +1086,9 @@ public void listen(FieldChangedEvent fieldChangedEvent) {
List<LinkedFile> newFileList = FileFieldParser.parse(fieldChangedEvent.getNewValue());

List<LinkedFile> addedFiles = new ArrayList<>(newFileList);
addedFiles.remove(oldFileList);
addedFiles.removeAll(oldFileList);
List<LinkedFile> removedFiles = new ArrayList<>(oldFileList);
removedFiles.remove(newFileList);
removedFiles.removeAll(newFileList);

try {
PdfIndexer indexer = PdfIndexerManager.getIndexer(bibDatabaseContext, preferencesService.getFilePreferences());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ public Path getFulltextIndexPath() {
Path indexPath;

if (getDatabasePath().isPresent()) {
Path databaseFileName = getDatabasePath().get().getFileName();
String fileName = BackupFileUtil.getUniqueFilePrefix(databaseFileName) + "--" + databaseFileName;
Path databasePath = getDatabasePath().get();
String fileName = BackupFileUtil.getUniqueFilePrefix(databasePath) + "--" + databasePath.getFileName();
indexPath = appData.resolve(fileName);
LOGGER.debug("Index path for {} is {}", getDatabasePath().get(), indexPath);
return indexPath;
Expand Down

0 comments on commit fcd6b9b

Please sign in to comment.