From 5206a33e78c4a03591dc5403f6a5496645d13f78 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 19 Sep 2024 09:39:59 -0500 Subject: [PATCH] Do not error if the `CACHEDIR.TAG` file exists but cannot be written to (#7550) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attempting to address the error in https://github.com/astral-sh/uv/issues/7434 — it seems overkill to fail if the file exists but isn't writable. --- crates/uv-fs/src/cachedir.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/uv-fs/src/cachedir.rs b/crates/uv-fs/src/cachedir.rs index e19625d89..cb2feb390 100644 --- a/crates/uv-fs/src/cachedir.rs +++ b/crates/uv-fs/src/cachedir.rs @@ -32,9 +32,13 @@ pub fn add_tag>(directory: P) -> io::Result<()> { /// Will return an error if The tag file doesn't exist and can't be created for any reason /// (the `directory` doesn't exist, permission error, can't write to the file etc.). pub fn ensure_tag>(directory: P) -> io::Result<()> { - match add_tag(directory) { + match add_tag(&directory) { Err(e) => match e.kind() { io::ErrorKind::AlreadyExists => Ok(()), + // If it exists, but we can't write to it for some reason don't fail + io::ErrorKind::PermissionDenied if directory.as_ref().join("CACHEDIR.TAG").exists() => { + Ok(()) + } _ => Err(e), }, other => other,