diff --git a/core/src/main/groovy/com/muwire/core/files/HasherService.groovy b/core/src/main/groovy/com/muwire/core/files/HasherService.groovy index b140cee0..f027a044 100644 --- a/core/src/main/groovy/com/muwire/core/files/HasherService.groovy +++ b/core/src/main/groovy/com/muwire/core/files/HasherService.groovy @@ -87,7 +87,7 @@ class HasherService { void onDirectoryUnsharedEvent(DirectoryUnsharedEvent evt) { for(File dir : evt.directories) - hashed.removeAll(dir) + hashed.remove(dir) } private synchronized void throttle(File f) { 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 4e1c7699..2a6fd67a 100644 --- a/core/src/main/groovy/com/muwire/core/files/PersisterFolderService.groovy +++ b/core/src/main/groovy/com/muwire/core/files/PersisterFolderService.groovy @@ -63,11 +63,15 @@ class PersisterFolderService extends BasePersisterService { } void onFileHashedEvent(FileHashedEvent hashedEvent) { + if (hashedEvent.sharedFile == null) + return if (core.getMuOptions().getAutoPublishSharedFiles() && hashedEvent.sharedFile != null) hashedEvent.sharedFile.publish(System.currentTimeMillis()) File file = hashedEvent.sharedFile.file - hashedEvent.sharedFile.setPathToSharedParent(findSharedParent(file)) + Path root = findSharedParent(file) + log.fine("PFS: for $file found root $root") + hashedEvent.sharedFile.setPathToSharedParent(root) persistFile(hashedEvent.sharedFile, hashedEvent.infoHash) } diff --git a/core/src/main/groovy/com/muwire/core/files/directories/WatchedDirectoryManager.groovy b/core/src/main/groovy/com/muwire/core/files/directories/WatchedDirectoryManager.groovy index 86a11782..14dd8bf1 100644 --- a/core/src/main/groovy/com/muwire/core/files/directories/WatchedDirectoryManager.groovy +++ b/core/src/main/groovy/com/muwire/core/files/directories/WatchedDirectoryManager.groovy @@ -131,17 +131,20 @@ class WatchedDirectoryManager { } void onFileSharedEvent(FileSharedEvent e) { - if (e.file.isFile() || watchedDirs.containsKey(e.file)) + File canonical = e.file.getCanonicalFile() + if (canonical.isFile() || watchedDirs.containsKey(canonical)) return - if (!settings.shareHiddenFiles && e.file.isHidden()) + if (!settings.shareHiddenFiles && canonical.isHidden()) return - def wd = new WatchedDirectory(e.file) + log.fine("WDM: watching directory $canonical") + + def wd = new WatchedDirectory(canonical) if (e.fromWatch) { // parent should be already watched, copy settings - def parent = watchedDirs.get(e.file.getParentFile()) + def parent = watchedDirs.get(canonical.getParentFile()) if (parent == null) { - log.severe("watching found a directory without a watched parent? ${e.file}") + log.severe("watching found a directory without a watched parent? ${canonical}") return } wd.autoWatch = parent.autoWatch