From 6cec0cab24bf80e5ca1fa7bea16174030e70d034 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Sun, 18 Oct 2026 16:24:03 -0600 Subject: [PATCH] Save: a read-only file is refused, so its metadata test asserts that MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main's 589941a5 (#6600) refuses to replace a read-only file before anything is written. This branch's test wrote to a 0o444 file and expected the save to succeed, so the merge of the two failed on Linux: cannot save .../doc.psd: the file is read-only; the original file was not changed No bug on either side: the two changes disagreed about what a read-only save should do, and main's answer is the deliberate one. The test now asserts the refusal, that the original is untouched, and that the attribute and mode survive — which is what it set out to check. The writable cases alongside it still cover the metadata copy itself. The windows-latest failure was the roll-up gate reporting this same failure, not a second one. --- crates/format/src/atomic/meta/tests.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/format/src/atomic/meta/tests.rs b/crates/format/src/atomic/meta/tests.rs index 8bf5689039..5c8f08c6ba 100644 --- a/crates/format/src/atomic/meta/tests.rs +++ b/crates/format/src/atomic/meta/tests.rs @@ -93,8 +93,8 @@ mod xattrs { assert_eq!(get(&p, TAG), Some(value)); } - /// Copying the mode must not get in the way of copying the attributes: a read-only file is - /// still writable to us *before* its mode lands on the temporary file, and only then. + /// A read-only file is refused outright (#6600), so a save never reaches the metadata copy and + /// the file keeps everything it had. The writable cases above cover the copy itself. #[test] fn a_read_only_file_keeps_its_attributes_and_its_mode() { use std::os::unix::fs::PermissionsExt; @@ -106,9 +106,13 @@ mod xattrs { } std::fs::set_permissions(&p, std::fs::Permissions::from_mode(0o444)).unwrap(); - atomic_write(&p, b"second, longer").unwrap(); + // #6600: a read-only file is refused before anything is written, so the question this test + // asks — does a replace keep the attributes and the mode — is answered by the save not + // happening. The writable case above covers attributes surviving a replace. + let e = atomic_write(&p, b"second, longer").expect_err("a read-only file is refused"); + assert_eq!(e.kind(), std::io::ErrorKind::PermissionDenied); - assert_eq!(std::fs::read(&p).unwrap(), b"second, longer"); + assert_eq!(std::fs::read(&p).unwrap(), b"first", "the original was left alone"); assert_eq!(get(&p, TAG).as_deref(), Some(&b"tagged"[..]), "a read-only file lost its attribute"); assert_eq!(std::fs::metadata(&p).unwrap().permissions().mode() & 0o777, 0o444); }