Populate symlink aliases on loading and fix sync/config for symlinks

dbus-notify
Zlatin Balevsky 2022-08-24 13:26:35 +01:00
parent c45c16d04c
commit e1a2c6ad21
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 9 additions and 12 deletions

View File

@ -72,18 +72,13 @@ class WatchedDirectoryManager {
synchronized Visibility getVisibility(File f) { synchronized Visibility getVisibility(File f) {
if (!isWatched(f)) if (!isWatched(f))
return Visibility.EVERYONE return Visibility.EVERYONE
WatchedDirectory wd = watchedDirs.get(f) return getDirectory(f).visibility
if (wd == null)
wd = aliasesMap.get(f)
return wd.visibility
} }
synchronized boolean isVisible(File f, Persona persona) { synchronized boolean isVisible(File f, Persona persona) {
if (!isWatched(f)) if (!isWatched(f))
return true return true
WatchedDirectory wd = watchedDirs.get(f) WatchedDirectory wd = getDirectory(f)
if (wd == null)
wd = aliasesMap.get(f)
if (wd.visibility == Visibility.EVERYONE) if (wd.visibility == Visibility.EVERYONE)
return true return true
if (wd.visibility == Visibility.CONTACTS) if (wd.visibility == Visibility.CONTACTS)
@ -103,7 +98,7 @@ class WatchedDirectoryManager {
} }
synchronized void onUISyncDirectoryEvent(UISyncDirectoryEvent e) { synchronized void onUISyncDirectoryEvent(UISyncDirectoryEvent e) {
def wd = watchedDirs.get(e.directory) def wd = getDirectory(e.directory)
if (wd == null) { if (wd == null) {
log.warning("Got a sync event for non-watched dir ${e.directory}") log.warning("Got a sync event for non-watched dir ${e.directory}")
return return
@ -122,10 +117,7 @@ class WatchedDirectoryManager {
persist(newDir) persist(newDir)
} else { } else {
e.toApply.each { e.toApply.each {
def wd def wd = getDirectory(it)
synchronized (this) {
wd = watchedDirs.get(it)
}
if (wd == null) { if (wd == null) {
log.severe("got a configuration event for a non-watched directory ${it}") log.severe("got a configuration event for a non-watched directory ${it}")
return return
@ -157,6 +149,11 @@ class WatchedDirectoryManager {
(settings.shareHiddenFiles || !wd.directory.isHidden())) { (settings.shareHiddenFiles || !wd.directory.isHidden())) {
synchronized (this) { synchronized (this) {
watchedDirs.put(wd.canonical, wd) watchedDirs.put(wd.canonical, wd)
if (wd.aliases != null) {
wd.aliases.each {
aliasesMap[it] = wd
}
}
} }
} }
else else