committed by
François-Xavier Thomas
parent
74b281a078
commit
e635055bf6
+18
-6
@@ -101,20 +101,28 @@ public class MusicFolderSettingsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void expunge() {
|
private synchronized void expunge() {
|
||||||
|
|
||||||
|
MediaLibraryStatistics statistics = indexManager.getStatistics();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* indexManager#expunge depends on DB delete flag.
|
||||||
|
* For consistency, clean of DB and Lucene must run in one block.
|
||||||
|
*
|
||||||
|
* Lucene's writing is exclusive.
|
||||||
|
* This process cannot be performed
|
||||||
|
* while during scan or scan has never been performed.
|
||||||
|
*/
|
||||||
|
if (statistics != null && !mediaScannerService.isScanning()) {
|
||||||
|
|
||||||
// to be before dao#expunge
|
// to be before dao#expunge
|
||||||
MediaLibraryStatistics statistics = indexManager.getStatistics();
|
|
||||||
if (statistics != null) {
|
|
||||||
LOG.debug("Cleaning search index...");
|
LOG.debug("Cleaning search index...");
|
||||||
indexManager.startIndexing();
|
indexManager.startIndexing();
|
||||||
indexManager.expunge();
|
indexManager.expunge();
|
||||||
indexManager.stopIndexing(statistics);
|
indexManager.stopIndexing(statistics);
|
||||||
LOG.debug("Search index cleanup complete.");
|
LOG.debug("Search index cleanup complete.");
|
||||||
} else {
|
|
||||||
LOG.warn("Missing index statistics - index probably hasn't been created yet. Not expunging index.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// to be after indexManager#expunge
|
||||||
LOG.debug("Cleaning database...");
|
LOG.debug("Cleaning database...");
|
||||||
LOG.debug("Deleting non-present artists...");
|
LOG.debug("Deleting non-present artists...");
|
||||||
artistDao.expunge();
|
artistDao.expunge();
|
||||||
@@ -124,6 +132,10 @@ public class MusicFolderSettingsController {
|
|||||||
mediaFileDao.expunge();
|
mediaFileDao.expunge();
|
||||||
LOG.debug("Database cleanup complete.");
|
LOG.debug("Database cleanup complete.");
|
||||||
mediaFileDao.checkpoint();
|
mediaFileDao.checkpoint();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
LOG.warn("Index hasn't been created yet or during scanning. Plese execute clean up after scan is completed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MusicFolderSettingsCommand.MusicFolderInfo> wrap(List<MusicFolder> musicFolders) {
|
private List<MusicFolderSettingsCommand.MusicFolderInfo> wrap(List<MusicFolder> musicFolders) {
|
||||||
|
|||||||
@@ -313,8 +313,10 @@ public class IndexManager {
|
|||||||
}
|
}
|
||||||
} catch (IndexNotFoundException e) {
|
} catch (IndexNotFoundException e) {
|
||||||
LOG.debug("Index {} does not exist in {}, likely not yet created.", indexType.toString(), indexDirectory.getAbsolutePath());
|
LOG.debug("Index {} does not exist in {}, likely not yet created.", indexType.toString(), indexDirectory.getAbsolutePath());
|
||||||
|
return null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.warn("Failed to initialize SearcherManager.", e);
|
LOG.warn("Failed to initialize SearcherManager.", e);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user