From 3825ce02e5cf0ca95f7fd62a01a58f2d13643ad1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 17:53:34 +0000 Subject: [PATCH 1/2] Initial plan From d0e7fde49f7536cafefe5f00bc59019b9f33f3d4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 17:55:46 +0000 Subject: [PATCH 2/2] Compute artifact digests by chunks to avoid loading large files into memory --- craft_application/models/manifest.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/craft_application/models/manifest.py b/craft_application/models/manifest.py index 2e721c449..50f1f10a8 100644 --- a/craft_application/models/manifest.py +++ b/craft_application/models/manifest.py @@ -37,13 +37,17 @@ class Hashes(CraftBaseModel): @classmethod def from_path(cls, path: pathlib.Path) -> Self: """Compute digests for a given path.""" - read_bytes = path.read_bytes() + sha1 = hashlib.sha1() # noqa: S324 (insecure hash function) + sha256 = hashlib.sha256() + + with path.open("rb") as f: + while chunk := f.read(65536): + sha1.update(chunk) + sha256.update(chunk) return cls( - sha1=hashlib.sha1( # noqa: S324 (insecure hash function) - read_bytes - ).hexdigest(), - sha256=hashlib.sha256(read_bytes).hexdigest(), + sha1=sha1.hexdigest(), + sha256=sha256.hexdigest(), )