canonicalize before checking if directory is watched. Add logging to debug GitHub issue #65

auto-update
Zlatin Balevsky 2021-10-07 04:51:05 +01:00
parent 2c3a0e5310
commit 6c55812721
No known key found for this signature in database
GPG Key ID: A72832072D525E41
3 changed files with 14 additions and 7 deletions

View File

@ -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) {

View File

@ -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)
}

View File

@ -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