diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 4631f819..1741aee9 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -268,6 +268,7 @@ public class Core { eventBus.register(FileLoadedEvent.class, persisterFolderService) eventBus.register(FileHashedEvent.class, persisterFolderService) eventBus.register(FileUnsharedEvent.class, persisterFolderService) + eventBus.register(UICommentEvent.class, persisterFolderService) log.info("initializing host cache") File hostStorage = new File(home, "hosts.json") diff --git a/core/src/main/groovy/com/muwire/core/files/PersisterFolderService.groovy b/core/src/main/groovy/com/muwire/core/files/PersisterFolderService.groovy index a0b6b7d5..b2899f05 100644 --- a/core/src/main/groovy/com/muwire/core/files/PersisterFolderService.groovy +++ b/core/src/main/groovy/com/muwire/core/files/PersisterFolderService.groovy @@ -88,6 +88,10 @@ class PersisterFolderService extends BasePersisterService { persistFile(loadedEvent.loadedFile, loadedEvent.infoHash) } } + + void onUICommentEvent(UICommentEvent e) { + persistFile(e.sharedFile,null) + } void load() { log.fine("Loading...") @@ -144,8 +148,10 @@ class PersisterFolderService extends BasePersisterService { writer.println json } - def hashListPath = getHashListPath(sf) - hashListPath.toFile().bytes = ih.hashList + if (ih != null) { + def hashListPath = getHashListPath(sf) + hashListPath.toFile().bytes = ih.hashList + } log.fine("Time(ms) to write json+hashList: " + (System.currentTimeMillis() - startTime)) } as Runnable) }