From 90925fd321bf4c999f8e243c341f412d6a232b8b Mon Sep 17 00:00:00 2001 From: Cabbagec Date: Sat, 25 Jul 2026 03:01:34 +0000 Subject: [PATCH] fix: use job-specific sparse transfer progress --- deploy/production/lithium/compose.yaml | 2 +- deploy/production/x1/compose.yaml | 2 +- deploy/production/x2/compose.yaml | 2 +- docs/deployment-and-usage.md | 2 +- pyproject.toml | 2 +- src/archive_clients/syncthing.py | 18 +++++++++++++----- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/deploy/production/lithium/compose.yaml b/deploy/production/lithium/compose.yaml index 1746922..e339a36 100644 --- a/deploy/production/lithium/compose.yaml +++ b/deploy/production/lithium/compose.yaml @@ -2,7 +2,7 @@ name: archive-control-archive services: archive-client: - image: sodium/archive-clients:v0.1.11 + image: sodium/archive-clients:v0.1.12 user: "1000:1000" restart: unless-stopped command: ["--config", "/etc/archive-control/client.toml"] diff --git a/deploy/production/x1/compose.yaml b/deploy/production/x1/compose.yaml index 8ebc07c..c0458ac 100644 --- a/deploy/production/x1/compose.yaml +++ b/deploy/production/x1/compose.yaml @@ -2,7 +2,7 @@ name: archive-control-cache services: archive-client: - image: sodium/archive-clients:v0.1.11 + image: sodium/archive-clients:v0.1.12 user: "1001:1001" restart: unless-stopped network_mode: host diff --git a/deploy/production/x2/compose.yaml b/deploy/production/x2/compose.yaml index e65d26f..fe05173 100644 --- a/deploy/production/x2/compose.yaml +++ b/deploy/production/x2/compose.yaml @@ -2,7 +2,7 @@ name: archive-control-cache services: archive-client: - image: sodium/archive-clients:v0.1.11 + image: sodium/archive-clients:v0.1.12 user: "1001:1001" restart: unless-stopped network_mode: host diff --git a/docs/deployment-and-usage.md b/docs/deployment-and-usage.md index 0a16319..5abc136 100644 --- a/docs/deployment-and-usage.md +++ b/docs/deployment-and-usage.md @@ -218,7 +218,7 @@ cache/archive routes according to policy. ```yaml services: archive-client: - image: sodium/archive-clients:v0.1.11 + image: sodium/archive-clients:v0.1.12 user: "1001:1001" restart: unless-stopped command: ["archive-client", "--config", "/etc/archive-control/client.toml"] diff --git a/pyproject.toml b/pyproject.toml index c1cf818..f51f35b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "archive-clients" -version = "0.1.11" +version = "0.1.12" requires-python = ">=3.11" dependencies = ["protobuf==7.35.1", "websockets==16.0"] diff --git a/src/archive_clients/syncthing.py b/src/archive_clients/syncthing.py index 563a89d..205afa6 100644 --- a/src/archive_clients/syncthing.py +++ b/src/archive_clients/syncthing.py @@ -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