← Back to issue list

Fix: deleted files from local sources now removed from part src directory on update

View original Github issue

Metadata

Project
craft-parts
Number
#1556
Type
pull request
State
open
Author
Copilot
Labels
Created
Updated
Closed

Current evaluation

Adds a .craft-parts-source-manifest to LocalSource so update() removes files deleted from the source, fixing open issue #851. Author revised the approach after maintainer feedback; review pending with 0 reviewers and only the CLA check passing.

Suggested action: needs review

Reason: Maintainer @lengau flagged that the original approach would delete intermediate objects and force rebuilds; the author revised it in bf342c6 to use a source manifest, but the PR still has 0 formal reviewers and review is pending. Issue #851 remains open and the current local_source.py has no manifest logic, so the fix is unmerged and needs a maintainer to review the revised approach (noting a prior attempt was reverted in #132).

Impact: 50 Quick Win: 20.0 Staleness: 45 Complexity: 60 Confidence: 70

Issue body

When a file was deleted from a local source, `update()` left the stale file in `part_src_dir` because `check_if_outdated()` only scanned the source for new/modified files and never detected deletions. ## Changes - **`pull()`** — after copying source files, writes a `.craft-parts-source-manifest` file to `part_src_dir` recording all source entries (files, directories, and directory symlinks) at that point in time. - **`check_if_outdated()`** — reads the manifest and compares it against the current source to detect deletions. Only the *source* is walked; the destination is never compared directly. If no manifest exists (e.g. before the first pull, or after a clean), deletion detection is skipped for backward compatibility. - **`update()`** — after copying new/modified files, removes stale files (`os.remove`) and directories (`shutil.rmtree`) detected via the manifest. Refreshes the manifest afterwards, but only if one already exists — preventing inadvertent manifest creation in contexts where `pull()` is never called (e.g. the `part_src_dir → part_build_dir` update in `_update_build`). - **Tests** — adds `test_file_removed`, `test_file_removed_from_subdirectory`, and `test_non_source_files_in_destination_not_deleted` to `TestLocalUpdate`. The last test explicitly verifies that files in the destination that were never in the source (e.g. build artifacts) are never removed. ## Example ```python # Before fix: file1 persists in destination even after being deleted from source os.remove("source/file1") local.update() assert not os.path.exists("destination/file1") # ← would FAIL before this fix ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 50
Quick Win: 20.0
Staleness: 45
Complexity: 60
Confidence: 70
needs review Adds a .craft-parts-source-manifest to LocalSource so update() removes files deleted from the source, fixing open issue #851. Author revised the approach after maintainer feedback; review pending with 0 reviewers and only the CLA check passing.
qwen/qwen3.6-35b-a3b
Staleness: 55
Complexity: 30
Confidence: 85
needs review Fixes stale file cleanup during local source updates by introducing a manifest file to track source entries. Currently pending maintainer review with passing CI and recent author response to feedback.
qwen3.6-35b-a3b-mtp-q6
Staleness: 55
Complexity: 45
Confidence: 65
needs review Fixes stale file cleanup during local source updates by introducing a manifest file to track source entries. Author addressed maintainer feedback with a commit, but the PR has been inactive for 78 days and awaits maintainer validation.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 40
Confidence: 75
needs review Fixes stale files persisting in part_src_dir after local source deletions. Uses a manifest file to track source state during pull, enabling accurate deletion detection during updates while preserving build artifacts. Merged and complete.

Update history

No update history recorded yet.

Related work

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

    This PR is the proposed fix for the open, triaged issue 'Removed files from local sources remain in the part'; the PR body and tests target exactly that behavior.

Related issues

No related issues found above the similarity threshold.