avoid running delete items task if there is no document deleted that is of interest

This commit is contained in:
Martin Lippert
2024-05-14 12:57:32 +02:00
parent 8f691f3575
commit 349f6c14ab

View File

@@ -646,22 +646,28 @@ public class SpringSymbolIndex implements InitializingBean, SpringIndex {
synchronized(this) {
try {
List<CompletableFuture<Void>> futures = new ArrayList<>();
Map<IJavaProject, Set<String>> projectMapping = getDocsPerProjectFromPaths(deletedPathURIs);
for (IJavaProject project : projectMapping.keySet()) {
Set<String> docURIs = projectMapping.get(project);
DeleteItems deleteItems = new DeleteItems(project, (String[]) docURIs.toArray(new String[docURIs.size()]), this.indexers);
CompletableFuture<Void> future = CompletableFuture.runAsync(deleteItems, this.updateQueue);
this.latestScheduledTaskByProject.put(project.getElementName(), future);
futures.add(future);
if (docURIs != null && docURIs.size() > 0) {
DeleteItems deleteItems = new DeleteItems(project, (String[]) docURIs.toArray(new String[docURIs.size()]), this.indexers);
CompletableFuture<Void> future = CompletableFuture.runAsync(deleteItems, this.updateQueue);
this.latestScheduledTaskByProject.put(project.getElementName(), future);
futures.add(future);
}
}
CompletableFuture<Void> future = CompletableFuture.allOf((CompletableFuture[]) futures.toArray(new CompletableFuture[futures.size()]));
future = future.thenAccept(v -> server.getClient().indexUpdated()).thenAccept(v -> listeners.fire(v));
return future;
if (futures.size() > 0) {
CompletableFuture<Void> future = CompletableFuture.allOf((CompletableFuture[]) futures.toArray(new CompletableFuture[futures.size()]));
future = future.thenAccept(v -> server.getClient().indexUpdated()).thenAccept(v -> listeners.fire(v));
return future;
}
else {
return CompletableFuture.completedFuture(null);
}
}
catch (Exception e) {
log.error("", e);