Skip to content

Commit

Permalink
introduce MAX_SIZE_RATIO for decision patch vs full update
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisvang committed Feb 9, 2024
1 parent 4bbe7be commit e2c3399
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tufup/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e2c3399

Please sign in to comment.