From 4222324246540fca83e00226bf88098eb89d58ac Mon Sep 17 00:00:00 2001 From: John Thomson Date: Thu, 5 Feb 2026 14:09:55 -0600 Subject: [PATCH] Don't create watcher for "other" directory if there isn't one (BL-15838) --- .../TeamCollection/FolderTeamCollection.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/BloomExe/TeamCollection/FolderTeamCollection.cs b/src/BloomExe/TeamCollection/FolderTeamCollection.cs index c0f1983e0630..e79d0857b949 100644 --- a/src/BloomExe/TeamCollection/FolderTeamCollection.cs +++ b/src/BloomExe/TeamCollection/FolderTeamCollection.cs @@ -825,10 +825,20 @@ protected internal override void StartMonitoring() // Begin watching. _booksWatcher.EnableRaisingEvents = true; - _otherWatcher = new FileSystemWatcherWrapper(Path.Combine(_repoFolderPath, "Other")); - _otherWatcher.NotifyFilter = NotifyFilters.LastWrite; - _otherWatcher.DebounceChanged(OnCollectionFilesChanged, kDebouncePeriodInMs); - _otherWatcher.EnableRaisingEvents = true; + var otherFilesDirPath = Path.Combine(_repoFolderPath, "Other"); + // If it doesn't exist we can't watch it. Rather bizarre since we normally create + // it if it doesn't exist as part of syncing. But BL-15838 seems to have been + // caused by not checking. If we can't set it up, unfortunately we won't find + // out immediately if some remote user modifies something in the collection. + // But we should find out on the next startup, and from then on we'll be able to + // monitor it, so I don't think it's very serious. + if (Directory.Exists(otherFilesDirPath)) + { + _otherWatcher = new FileSystemWatcherWrapper(otherFilesDirPath); + _otherWatcher.NotifyFilter = NotifyFilters.LastWrite; + _otherWatcher.DebounceChanged(OnCollectionFilesChanged, kDebouncePeriodInMs); + _otherWatcher.EnableRaisingEvents = true; + } } private void OnDeleted(object sender, FileSystemEventArgs e)