Skip to content

Commit

Permalink
Revert "Fix for Indexing stopping while having library modification (#…
Browse files Browse the repository at this point in the history
…8469)" (#8511)

This reverts commit d6fec0b.
  • Loading branch information
Siedlerchr authored Feb 19, 2022
1 parent 4fee3c4 commit f58ab67
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where an exception could occur when saving the preferences [#7614](https://github.com/JabRef/jabref/issues/7614)
- We fixed an issue where "Copy DOI url" in the right-click menu of the Entry List would just copy the DOI and not the DOI url. [#8389](https://github.com/JabRef/jabref/issues/8389)
- We fixed an issue where opening the console from the drop-down menu would cause an exception. [#8466](https://github.com/JabRef/jabref/issues/8466)
- We fixed an issue where modifying a library would trigger reindexing of all PDFs [#8420](https://github.com/JabRef/jabref/issues/8420)

### Removed

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class LibraryTab extends Tab {
// initializing it so we prevent NullPointerException
private BackgroundTask<ParserResult> dataLoadingTask = BackgroundTask.wrap(() -> null);

private final IndexingTaskManager indexingTaskManager = new IndexingTaskManager(Globals.TASK_EXECUTOR, bibDatabaseContext);
private final IndexingTaskManager indexingTaskManager = new IndexingTaskManager(Globals.TASK_EXECUTOR);

public LibraryTab(JabRefFrame frame,
PreferencesService preferencesService,
Expand Down Expand Up @@ -337,6 +337,10 @@ public void updateTabTitle(boolean isChanged) {
textProperty().setValue(tabTitle.toString());
setTooltip(new Tooltip(toolTipText.toString()));
});

if (preferencesService.getFilePreferences().shouldFulltextIndexLinkedFiles()) {
indexingTaskManager.updateDatabaseName(tabTitle.toString());
}
}

private List<String> collectAllDatabasePaths() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.jabref.logic.pdf.search.indexing;

import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

Expand All @@ -13,7 +11,6 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.event.EntryChangedEvent;

/**
* Wrapper around {@link PdfIndexer} to execute all operations in the background.
Expand All @@ -22,16 +19,14 @@ public class IndexingTaskManager extends BackgroundTask<Void> {

private final Queue<Runnable> taskQueue = new ConcurrentLinkedQueue<>();
private TaskExecutor taskExecutor;
private final BibDatabaseContext bibDatabaseContext;
private int numOfIndexedFiles = 0;

private final Object lock = new Object();
private boolean isRunning = false;
private boolean isBlockingNewTasks = false;

public IndexingTaskManager(TaskExecutor taskExecutor, BibDatabaseContext bibDatabaseContext) {
public IndexingTaskManager(TaskExecutor taskExecutor) {
this.taskExecutor = taskExecutor;
this.bibDatabaseContext = bibDatabaseContext;
showToUser(true);
DefaultTaskExecutor.runInJavaFXThread(() -> {
this.updateProgress(1, 1);
Expand Down Expand Up @@ -120,29 +115,7 @@ public void removeFromIndex(PdfIndexer indexer, BibEntry entry) {
enqueueTask(() -> removeFromIndex(indexer, entry, entry.getFiles()));
}

public void updateDatabaseName() {
Optional<Path> file = bibDatabaseContext.getDatabasePath();

String name = "";

try {
name = bibDatabaseContext.getDatabasePath().toString();
} finally {
if (file.isPresent()) {
Path databasePath = file.get();
name = databasePath.getFileName().toString();
}

String fileName = name;
DefaultTaskExecutor.runInJavaFXThread(() -> this.titleProperty().set(Localization.lang("Indexing for %0", fileName)));
}
}

public void updateDatabaseName(String name) {
DefaultTaskExecutor.runInJavaFXThread(() -> this.titleProperty().set(Localization.lang("Indexing for %0", name)));
}

public void listen(EntryChangedEvent event) {
updateDatabaseName();
}
}

0 comments on commit f58ab67

Please sign in to comment.