This commit is contained in:
parent
60e8630413
commit
ec86db176e
|
@ -37,8 +37,10 @@ func (f *sendOnlyFolder) PullErrors() []FileError {
|
||||||
|
|
||||||
// pull checks need for files that only differ by metadata (no changes on disk)
|
// pull checks need for files that only differ by metadata (no changes on disk)
|
||||||
func (f *sendOnlyFolder) pull() (bool, error) {
|
func (f *sendOnlyFolder) pull() (bool, error) {
|
||||||
batch := make([]protocol.FileInfo, 0, maxBatchSizeFiles)
|
batch := newFileInfoBatch(func(files []protocol.FileInfo) error {
|
||||||
batchSizeBytes := 0
|
f.updateLocalsFromPulling(files)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
snap, err := f.dbSnapshot()
|
snap, err := f.dbSnapshot()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -46,45 +48,40 @@ func (f *sendOnlyFolder) pull() (bool, error) {
|
||||||
}
|
}
|
||||||
defer snap.Release()
|
defer snap.Release()
|
||||||
snap.WithNeed(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool {
|
snap.WithNeed(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool {
|
||||||
if len(batch) == maxBatchSizeFiles || batchSizeBytes > maxBatchSizeBytes {
|
batch.flushIfFull()
|
||||||
f.updateLocalsFromPulling(batch)
|
|
||||||
batch = batch[:0]
|
file := intf.(protocol.FileInfo)
|
||||||
batchSizeBytes = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if f.ignores.ShouldIgnore(intf.FileName()) {
|
if f.ignores.ShouldIgnore(intf.FileName()) {
|
||||||
file := intf.(protocol.FileInfo)
|
|
||||||
file.SetIgnored()
|
file.SetIgnored()
|
||||||
batch = append(batch, file)
|
batch.append(file)
|
||||||
batchSizeBytes += file.ProtoSize()
|
|
||||||
l.Debugln(f, "Handling ignored file", file)
|
l.Debugln(f, "Handling ignored file", file)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
curFile, ok := snap.Get(protocol.LocalDeviceID, intf.FileName())
|
curFile, ok := snap.Get(protocol.LocalDeviceID, intf.FileName())
|
||||||
if !ok {
|
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")
|
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")
|
f.evLogger.Log(events.Failure, "got deleted file that doesn't exist locally as needed when pulling on send-only")
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
file := intf.(protocol.FileInfo)
|
|
||||||
if !file.IsEquivalentOptional(curFile, f.modTimeWindow, f.IgnorePerms, false, 0) {
|
if !file.IsEquivalentOptional(curFile, f.modTimeWindow, f.IgnorePerms, false, 0) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
batch = append(batch, file)
|
batch.append(file)
|
||||||
batchSizeBytes += file.ProtoSize()
|
|
||||||
l.Debugln(f, "Merging versions of identical file", file)
|
l.Debugln(f, "Merging versions of identical file", file)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(batch) > 0 {
|
batch.flush()
|
||||||
f.updateLocalsFromPulling(batch)
|
|
||||||
}
|
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue