Fix: deleted files from local sources now removed from part src directory on update
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
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
No evaluation history available.