Commit 8e43074
authored
fix(package): exclude target/package from backups (#16272)
### What does this PR try to resolve?
The target directory is not excluded from backups when created with
`cargo package` or `cargo publish`. This causes the `target/package`
directory to be included in Time Machine backups on macOS and other
backup systems that respect CACHEDIR.TAG files.
The issue occurs because when `Filesystem::open()` creates parent
directories in `src/cargo/util/flock.rs:336`, it uses
`paths::create_dir_all()` instead of the backup-excluding version,
bypassing the normal target directory creation logic.
This commit adds a new `create_dir_with_backup_exclusion()` method to
`Filesystem` and uses it to ensure the `target/package` directory is
properly excluded from backups before creating files in it.
Fixes #16238
### How to test and review this PR?
Run the following:
cargo new foo
cd foo
cargo package --allow-dirty
ls -al target/package/
Verify that `CACHEDIR.TAG` now exists in `target/package/`.
All existing package tests pass.File tree
4 files changed
+36
-1
lines changed- src/cargo/ops/cargo_package
- tests/testsuite
4 files changed
+36
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| |||
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
| 230 | + | |
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| 528 | + | |
528 | 529 | | |
529 | 530 | | |
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
| 536 | + | |
535 | 537 | | |
536 | 538 | | |
537 | 539 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
| 497 | + | |
497 | 498 | | |
498 | 499 | | |
499 | 500 | | |
500 | 501 | | |
501 | 502 | | |
502 | 503 | | |
503 | 504 | | |
| 505 | + | |
504 | 506 | | |
505 | 507 | | |
506 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7804 | 7804 | | |
7805 | 7805 | | |
7806 | 7806 | | |
| 7807 | + | |
| 7808 | + | |
| 7809 | + | |
| 7810 | + | |
| 7811 | + | |
| 7812 | + | |
| 7813 | + | |
| 7814 | + | |
| 7815 | + | |
| 7816 | + | |
| 7817 | + | |
| 7818 | + | |
| 7819 | + | |
| 7820 | + | |
| 7821 | + | |
| 7822 | + | |
| 7823 | + | |
| 7824 | + | |
| 7825 | + | |
| 7826 | + | |
| 7827 | + | |
| 7828 | + | |
| 7829 | + | |
| 7830 | + | |
| 7831 | + | |
| 7832 | + | |
| 7833 | + | |
| 7834 | + | |
0 commit comments