Skip to content

Commit

Permalink
Merge pull request #484 from kagemomiji/issue473-show-log-expunge
Browse files Browse the repository at this point in the history
#473 change the log rule for expunge to show log
  • Loading branch information
kagemomiji authored May 25, 2024
2 parents a1c8c3a + 3721d73 commit 97a37d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,32 +125,35 @@ private void expunge() {
// to be before dao#expunge
MediaLibraryStatistics statistics = indexManager.getStatistics();
if (statistics != null) {
LOG.debug("Cleaning search index...");
indexManager.startIndexing();
indexManager.expunge();
indexManager.stopIndexing(statistics);
LOG.debug("Search index cleanup complete.");
LOG.info("Cleaning search index...");
if (indexManager.startIndexing()) {
indexManager.expunge();
indexManager.stopIndexing(statistics);
LOG.info("Search index cleanup complete.");
} else {
LOG.info("Search index is currently being updated. Skipping cleanup.");
}
} else {
LOG.warn("Missing index statistics - index probably hasn't been created yet. Not expunging index.");
}

LOG.debug("Cleaning database...");
LOG.debug("Deleting non-present cover art...");
LOG.info("Cleaning database...");
LOG.info("Deleting non-present cover art...");
coverArtService.expunge();
LOG.debug("Deleting non-present artists...");
LOG.info("Deleting non-present artists...");
artistService.expunge();
LOG.debug("Deleting non-present albums...");
LOG.info("Deleting non-present albums...");
albumService.expunge();
LOG.debug("Deleting non-present media files...");
LOG.info("Deleting non-present media files...");
mediaFileService.expunge();
LOG.debug("Deleting non-present media folders...");
LOG.info("Deleting non-present media folders...");
mediaFolderService.expunge();
LOG.debug("Refreshing playlist stats...");
LOG.info("Refreshing playlist stats...");
List<Playlist> playlists = playlistService.refreshPlaylistsStats();
playlists.forEach(p -> {
playlistService.broadcastFileChange(p.getId(), false, false);
});
LOG.debug("Database cleanup complete.");
LOG.info("Database cleanup complete.");
}

private List<MusicFolderSettingsCommand.MusicFolderInfo> wrap(List<MusicFolder> musicFolders) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,16 @@ public void index(MediaFile mediaFile, MusicFolder musicFolder) {
}
}

public final void startIndexing() {
EnumSet.allOf(IndexType.class).parallelStream().forEach(x -> {
public final boolean startIndexing() {
return EnumSet.allOf(IndexType.class).parallelStream().map(x -> {
try {
writers.put(x, createIndexWriter(x));
} catch (IOException e) {
LOG.error("Failed to create search index for {}", x, e);
return false;
}
});
return true;
}).reduce(true, (a, b) -> a && b);
}

private IndexWriter createIndexWriter(IndexType indexType) throws IOException {
Expand Down

0 comments on commit 97a37d9

Please sign in to comment.