jdb: Fix index not deleting

This commit is contained in:
Oliver
2025-11-20 14:46:16 +01:00
parent 09363fe010
commit c0998aabdb
2 changed files with 9 additions and 3 deletions

View File

@@ -1 +1 @@
1.0.3
1.0.4

View File

@@ -9,6 +9,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -170,7 +171,12 @@ public class JDB {
* @param path the relative path (excluding .json extension) of the document(s) to be deleted
*/
public void delete(@NotNull String path) {
index.indexMap().remove(path);
for (Map.Entry<String, String> entry : new HashSet<>(index.indexMap().entrySet())) {
if (entry.getKey().equals(path) || entry.getValue().equals(path)) {
index.indexMap().remove(entry.getKey());
index.save();
}
}
File file = new File(baseDirectory, path);
if (file.isDirectory()) {