diff options
author | Simon Frei <freisim93@gmail.com> | 2021-04-26 15:36:51 +0200 |
---|---|---|
committer | Jakob Borg <jakob@kastelo.net> | 2021-04-26 15:38:08 +0200 |
commit | ec86db176edc23ad2375c5d53c9f12967836b42b (patch) | |
tree | 10ca440e23e4e01fadcc64c6795571779939433d | |
parent | 60e8630413cf1609147d83397fbf65b2fe2d9042 (diff) | |
download | syncthing-1.16.0-rc.3.tar.gz syncthing-1.16.0-rc.3.zip |
lib/model: Handle invalid needed items on send-only (ref #7476) (#7596)v1.16.0-rc.3v1.16.0
-rw-r--r-- | lib/model/folder_sendonly.go | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/model/folder_sendonly.go b/lib/model/folder_sendonly.go index 861c9440c..752101caa 100644 --- a/lib/model/folder_sendonly.go +++ b/lib/model/folder_sendonly.go @@ -37,8 +37,10 @@ func (f *sendOnlyFolder) PullErrors() []FileError { // pull checks need for files that only differ by metadata (no changes on disk) func (f *sendOnlyFolder) pull() (bool, error) { - batch := make([]protocol.FileInfo, 0, maxBatchSizeFiles) - batchSizeBytes := 0 + batch := newFileInfoBatch(func(files []protocol.FileInfo) error { + f.updateLocalsFromPulling(files) + return nil + }) snap, err := f.dbSnapshot() if err != nil { @@ -46,45 +48,40 @@ func (f *sendOnlyFolder) pull() (bool, error) { } defer snap.Release() snap.WithNeed(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool { - if len(batch) == maxBatchSizeFiles || batchSizeBytes > maxBatchSizeBytes { - f.updateLocalsFromPulling(batch) - batch = batch[:0] - batchSizeBytes = 0 - } + batch.flushIfFull() + + file := intf.(protocol.FileInfo) if f.ignores.ShouldIgnore(intf.FileName()) { - file := intf.(protocol.FileInfo) file.SetIgnored() - batch = append(batch, file) - batchSizeBytes += file.ProtoSize() + batch.append(file) l.Debugln(f, "Handling ignored file", file) return true } curFile, ok := snap.Get(protocol.LocalDeviceID, intf.FileName()) if !ok { - if intf.IsDeleted() { + if intf.IsInvalid() { + // Global invalid file just exists for need accounting + batch.append(file) + } else if intf.IsDeleted() { l.Debugln("Should never get a deleted file as needed when we don't have it") f.evLogger.Log(events.Failure, "got deleted file that doesn't exist locally as needed when pulling on send-only") } return true } - file := intf.(protocol.FileInfo) if !file.IsEquivalentOptional(curFile, f.modTimeWindow, f.IgnorePerms, false, 0) { return true } - batch = append(batch, file) - batchSizeBytes += file.ProtoSize() + batch.append(file) l.Debugln(f, "Merging versions of identical file", file) return true }) - if len(batch) > 0 { - f.updateLocalsFromPulling(batch) - } + batch.flush() return true, nil } |