Skip to content

Commit

Permalink
Auto merge of #13132 - arlosi:cachedir, r=epage
Browse files Browse the repository at this point in the history
Avoid writing CACHEDIR.TAG if it already exists

Cargo currently unconditionally writes `CACHEDIR.TAG` files even if they already exist.

This practice causes problems for build systems that disallow multiple writes to the same file.
  • Loading branch information
bors committed Dec 7, 2023
2 parents bdef274 + 04af5e7 commit 749654c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/cargo-util/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,17 @@ pub fn exclude_from_backups_and_indexing(p: impl AsRef<Path>) {
/// * CACHEDIR.TAG files supported by various tools in a platform-independent way
fn exclude_from_backups(path: &Path) {
exclude_from_time_machine(path);
let _ = std::fs::write(
path.join("CACHEDIR.TAG"),
"Signature: 8a477f597d28d172789f06886806bc55
let file = path.join("CACHEDIR.TAG");
if !file.exists() {
let _ = std::fs::write(
file,
"Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/
",
);
// Similarly to exclude_from_time_machine() we ignore errors here as it's an optional feature.
);
// Similarly to exclude_from_time_machine() we ignore errors here as it's an optional feature.
}
}

/// Marks the directory as excluded from content indexing.
Expand Down

0 comments on commit 749654c

Please sign in to comment.