From e2c3399ed37b604c628b6e240329acb17d5626bb Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Fri, 9 Feb 2024 22:49:14 +0100 Subject: [PATCH] introduce MAX_SIZE_RATIO for decision patch vs full update --- src/tufup/client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tufup/client.py b/src/tufup/client.py index abf41d4..d73cf25 100644 --- a/src/tufup/client.py +++ b/src/tufup/client.py @@ -19,6 +19,8 @@ DEFAULT_EXTRACT_DIR = pathlib.Path(tempfile.gettempdir()) / 'tufup' SUFFIX_FAILED = '.failed' +# do full update if patch-size/full-size > MAX_SIZE_RATIO +MAX_SIZE_RATIO = 0.8 class Client(tuf.ngclient.Updater): @@ -208,7 +210,9 @@ def check_for_updates( # is not available, we must do a full update) self.new_targets = new_patches no_patches = total_patch_size == 0 - patch_too_big = total_patch_size > self.new_archive_info.length + patch_too_big = ( + total_patch_size / self.new_archive_info.length > MAX_SIZE_RATIO + ) no_archive = not self.current_archive_local_path.exists() if not patch or no_patches or patch_too_big or no_archive or abort_patch: # fall back on full update