fix: publish initial sparse transfer progress

This commit is contained in:
2026-07-25 02:50:22 +00:00
parent d2fa69a1d6
commit 9df2e6991e
7 changed files with 60 additions and 8 deletions
+12 -3
View File
@@ -175,7 +175,12 @@ class ClientJobExecutor:
if event_callback is not None:
for event in emitted:
event_callback(event)
speed_sample = [time.monotonic(), 0]
# A newly-started step must publish its first observation. In
# particular, a sparse Syncthing temporary file may retain the same
# allocated-block count for a long time while data is still needed;
# suppressing that first observation made a healthy transfer look
# permanently stalled to the control daemon.
speed_sample: list[float | int | None] = [None, 0]
def progress(
fraction: float,
@@ -185,8 +190,12 @@ class ClientJobExecutor:
) -> None:
nonlocal cursor
now = time.monotonic()
elapsed = now - float(speed_sample[0])
if fraction < 1 and elapsed < 1:
previous_time = speed_sample[0]
elapsed = (
now - float(previous_time)
if previous_time is not None else 0.0
)
if previous_time is not None and fraction < 1 and elapsed < 1:
return
speed = (
max(0, bytes_complete - int(speed_sample[1])) / elapsed