Skip to content

Commit

Permalink
Fixes for warning on OSX because of double entries in menu bar
Browse files Browse the repository at this point in the history
Fixes for search index where unchecked exception interrupted the index build up
Run search index only after 14 days instat of always on startup causing 25% CPU usage
  • Loading branch information
lanthale committed May 12, 2024
1 parent 839af88 commit 2f9225a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions PhotoSlide/src/main/java/org/photoslide/search/SearchIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ protected Void call() throws Exception {
Files.walkFileTree(pathItem.getFilePath(), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(final Path fileItem, final BasicFileAttributes attrs) throws IOException {
if (task.isCancelled()) {
return FileVisitResult.TERMINATE;
}
int pathlength = fileItem.toString().length();
if (pathlength > 35) {
updateMessage("..." + fileItem.toString().substring(pathlength - 35, pathlength));
Expand Down Expand Up @@ -130,7 +133,7 @@ public FileVisitResult visitFile(final Path fileItem, final BasicFileAttributes
insertMediaFileIntoSearchDB(collectionName, m);
}
} catch (Throwable ex) {
Logger.getLogger(SearchIndex.class.getName()).log(Level.FINEST, "Cannot read " + m.getName() + " - " + m.getPathStorage(), ex);
Logger.getLogger(SearchIndex.class.getName()).log(Level.FINEST, "Cannot read " + m.getName() + " - " + m.getPathStorage(), ex);
}
}
}
Expand All @@ -140,8 +143,11 @@ public FileVisitResult visitFile(final Path fileItem, final BasicFileAttributes
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException e)
throws IOException {
if (task.isCancelled()) {
return FileVisitResult.TERMINATE;
}
boolean finishedSearch = Files.isSameFile(dir, pathItem.getFilePath());
if (finishedSearch) {
if (finishedSearch) {
App.setSEARCHINDEXFINISHED(LocalDate.now());
checkSearchIndex(pathItem.getFilePath().toString());
return FileVisitResult.TERMINATE;
Expand Down

0 comments on commit 2f9225a

Please sign in to comment.