← Back to issue list

fix(deb): avoid re-downloading cached stage-packages

View original Github issue

Metadata

Project
craft-parts
Number
#1553
Type
pull request
State
open
Author
gcomneno
Labels
—
Created
Updated
Closed
—

Current evaluation

External-contributor PR adding a narrow monkey-patch of apt.package._file_is_same (binary mode, order-independent hash compare) around candidate.fetch_binary in AptCache.fetch_archives, so warm-cache .deb files count as cache hits. +90/-5, 2 files, no reviewers yet.

Suggested action: needs review

Reason: The fix is still applicable — I confirmed current main's `craft_parts/packages/apt_cache.py:256` still calls `package.candidate.fetch_binary(...)` directly with no `_file_is_same` patch anywhere in the repo (grep for '_file_is_same' returns zero hits), and issue #1495 remains open specifically tracking this. The author has now rebased onto main, states the patch applies cleanly, and reports the two regression tests passing. However, CI shows `lint / files` failing (author says a formatting issue was fixed but this is unverified post-fix), the arm64 Java-plugin failure was a mirror 404 the author cannot rerun, and zero reviewers have weighed in on a monkey-patch of a private python-apt API — a maintainer decision on approach, not a rubber stamp.

Evaluated by: mr-cal-bot

Impact: 45 Quick Win: 9 Complexity: 55 Confidence: 72 Actionability: 45

Issue body

## Summary Mitigate repeated `.deb` downloads from a warm cache in the `stage-packages` / apt-cache path. This wraps `package.candidate.fetch_binary(...)` with a narrow local patch for `apt.package._file_is_same`, using: - binary file mode - order-independent hash comparison so cached `.deb` files that already match the expected metadata are treated as cache hits. ## Context Refs #1495. This is intentionally scoped to the `stage-packages` / apt-cache download path. It is related to, but separate from, #1485, which reduces some `python-apt` usage in the installed-package check path. ## Testing - `ruff check craft_parts/packages/apt_cache.py tests/unit/packages/test_apt_cache.py` - `pytest -q tests/unit/packages/test_apt_cache.py -rs` - `pytest -q tests/unit/packages/test_deb.py -rs` - `pytest -q tests/unit/packages -rs`

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 45
Quick Win: 9
Complexity: 55
Confidence: 72
Actionability: 45
needs review External-contributor PR adding a narrow monkey-patch of apt.package._file_is_same (binary mode, order-independent hash compare) around candidate.fetch_binary in AptCache.fetch_archives, so warm-cache .deb files count as cache hits. +90/-5, 2 files, no reviewers yet.
stealth/space-bunny-alpha
Impact: 45
Quick Win: 11
Complexity: 50
Confidence: 72
Actionability: 50
needs review Wraps package.candidate.fetch_binary in AptCache.fetch_archives with a narrow monkeypatch of apt.package._file_is_same (binary mode + order-independent hash compare) so cached .deb files count as cache hits; refs #1495. Adds 2 regression tests. Open 162 days, no reviews.
qwen/qwen3.6-35b-a3b
Impact: 55
Quick Win: 29
Complexity: 25
Confidence: 75
Actionability: 70
needs review Mitigates repeated .deb downloads in stage-packages path by patching apt.package._file_is_same for order-independent hash comparison. Rebased, CI mostly passing, awaiting maintainer review.
qwen/qwen3.6-35b-a3b
Impact: 65
Quick Win: 36
Staleness: 25
Complexity: 45
Confidence: 75
needs review Workaround for python-apt _file_is_same bug causing repeated stage-packages .deb downloads. PR rebased, CI mostly green, awaiting maintainer review.
qwen/qwen3.8-27b
Impact: 45
Quick Win: 22
Staleness: 45
Complexity: 50
Confidence: 80
needs review Patches apt-cache to treat cached .debs matching expected metadata as cache hits, avoiding repeated stage-packages re-downloads (workaround for python-apt _file_is_same bug). Awaiting review; CI mostly green with a few unrelated failures.
qwen/qwen3.6-35b-a3b
Staleness: 55
Complexity: 25
Confidence: 65
needs review Patches apt-cache to skip re-downloading cached .deb files via improved hash comparison. Currently pending maintainer review with zero approvals, minor unrelated CI failures, and last contributor activity 47 days ago.
qwen3.6-35b-a3b-mtp-q6
Staleness: 25
Complexity: 25
Confidence: 60
needs review Patches apt cache logic to prevent redundant .deb downloads by improving cache hit detection. Branch rebased, lint fixed, and tests updated. Awaiting maintainer review after unrelated CI failure.

Update history

Date Change
updated
updated

Related work

  • Related To: craft-parts#1495 (confidence 95%)

    Tracking issue explicitly cited in the PR body; still open and describes the same python-apt _file_is_same cache-miss bug.

  • Related To: craft-parts#1485 (confidence 90%)

    Already merged (a98be83a); removed python-apt from the installed-package check path. PR body notes it is a separate, complementary change.

Related issues

Issue Project State Summary Similarity
#1495 Bug: stage-packages re-downloaded on every run due to python-apt _file_is_same() bug craft-parts open Valid, triaged performance bug: python-apt's _file_is_same() order-sensitive hash compare makes apt_cache.fetch_archives() re-download stage-packages despite a warm deb cache. Maintainer gcomneno drafted fix PR #1553 (open, unreviewed); not yet fixed in craft-parts main.
74%