Skip to content

Avoid writing CACHEDIR.TAG if it already exists #13132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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