fix: use job-specific sparse transfer progress

This commit is contained in:
2026-07-25 03:01:34 +00:00
parent 9df2e6991e
commit 90925fd321
6 changed files with 18 additions and 10 deletions
+13 -5
View File
@@ -192,11 +192,19 @@ class SyncthingTransferObserver:
for relative_path, expected_bytes in declared_files
)
observed_fraction = observed_bytes / total if total else 1.0
# Folder completion remains useful when Syncthing has already
# atomically published a file but still reports it in its need
# queue; the allocated-byte estimate is needed for sparse temp
# files that are pre-sized before their blocks arrive.
fraction = min(observed_fraction, float(raw_fraction) / 100)
# ``/db/completion`` is folder-wide. It can be near zero when a
# route contains a freshly-created item even though the tracked
# job's temporary payload has already received many blocks. For
# an incomplete temporary file, its allocated blocks are the only
# job-specific signal, so do not cap them with that unrelated
# folder aggregate. Once every declared file is atomically
# present, retain the completion value as a conservative guard
# until the need queue has caught up.
fraction = (
observed_fraction
if observed_fraction < 1.0
else min(1.0, float(raw_fraction) / 100)
)
completed_bytes = int(total * fraction)
if complete:
fraction = 1.0