fix(model): check if remote folder state before pulling files (fixes #9686) (#9732)

### Purpose

As discussed in #9686 
Syncthing currently does not check folderstate on remote device before
pulling. If no devices have a valid folderstate (i.e all devices have
the folder paused) it will still attempt to pull. On large folders this
will cause a hanging "Syncing" status.

This checks whether at least one connected device has the file available
and has a valid folderstate.

### Testing
Tested locally on multiple devices.
We're new to Go (all our stuff is Python) so please bear with!
Interested if there may be a better place to slot this in.

Thanks,
Jon

---------

Co-authored-by: Simon Frei <freisim93@gmail.com>
This commit is contained in:
Hireworks
2024-11-12 08:51:52 +01:00
committed by GitHub
co-authored by Simon Frei
parent 955ac7775e
commit 36ef17df8f
2 changed files with 28 additions and 13 deletions
+5 -8
View File
@@ -505,13 +505,10 @@ nextFile:
continue nextFile
}
devices := snap.Availability(fileName)
for _, dev := range devices {
if f.model.ConnectedTo(dev) {
// Handle the file normally, by copying and pulling, etc.
f.handleFile(fi, snap, copyChan)
continue nextFile
}
devices := f.model.fileAvailability(f.FolderConfiguration, snap, fi)
if len(devices) > 0 {
f.handleFile(fi, snap, copyChan)
continue
}
f.newPullError(fileName, errNotAvailable)
f.queue.Done(fileName)
@@ -1547,7 +1544,7 @@ func (f *sendReceiveFolder) pullBlock(state pullBlockState, snap *db.Snapshot, o
}
var lastError error
candidates := f.model.availabilityInSnapshot(f.FolderConfiguration, snap, state.file, state.block)
candidates := f.model.blockAvailability(f.FolderConfiguration, snap, state.file, state.block)
loop:
for {
select {