aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric P <eric@kastelo.net>2023-12-13 12:34:24 +0100
committerGitHub <noreply@github.com>2023-12-13 12:34:24 +0100
commite8d3529fed21a1c21581283b22dbf31335edb990 (patch)
tree60cc3134e6f323265c207a057005cfb91d297cad
parent935a28c9612b4134d49e13a57e15aaa432f031a3 (diff)
downloadsyncthing-e8d3529fed21a1c21581283b22dbf31335edb990.tar.gz
syncthing-e8d3529fed21a1c21581283b22dbf31335edb990.zip
lib/model: Only handle relevant folder summaries (kqueue) (fixes #9183) (#9288)
On kqueue-systems, folders listen for folder summaries to (be able to) warn for potential high resource usage. However, it listened for any folder summary and not for the summary which matches the folder it's about. This could cause that an unwatched folder causes a folder summary containing more files than the threshold (10k), and the listening folder (with the watcher enabled) triggers the warning. This makes sure that only the folder summaries which are relevant to the specific folder are being handled. ### Testing - Fire up some kqueue-system (freebsd, I used). - add folder A, disable the watcher, add 10001 files - add folder B with the watcher enabled, no files are needed here Before the change: - add an item to folder A, trigger a rescan to speed up the process - wait some seconds...warning triggered by folder B's summarySubscription After the change: - Only a warning is triggered if the received folder summary matches the folder which listens for the summaries
-rw-r--r--lib/model/folder.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/model/folder.go b/lib/model/folder.go
index e69025d74..108861f16 100644
--- a/lib/model/folder.go
+++ b/lib/model/folder.go
@@ -1065,7 +1065,7 @@ func (f *folder) monitorWatch(ctx context.Context) {
case ev := <-summaryChan:
if data, ok := ev.Data.(FolderSummaryEventData); !ok {
f.evLogger.Log(events.Failure, "Unexpected type of folder-summary event in folder.monitorWatch")
- } else if data.Summary.LocalTotalItems-data.Summary.LocalDeleted > kqueueItemCountThreshold {
+ } else if data.Folder == f.folderID && data.Summary.LocalTotalItems-data.Summary.LocalDeleted > kqueueItemCountThreshold {
f.warnedKqueue = true
summarySub.Unsubscribe()
summaryChan = nil