Commit 4d928f4
committed
fix(package): exclude target/package from backups
### 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.1 parent b5354b5 commit 4d928f4
2 files changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| |||
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
| |||
1128 | 1130 | | |
1129 | 1131 | | |
1130 | 1132 | | |
1131 | | - | |
| 1133 | + | |
1132 | 1134 | | |
1133 | 1135 | | |
1134 | 1136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
214 | 225 | | |
215 | 226 | | |
216 | 227 | | |
| |||
0 commit comments