mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Save: a read-only file is refused, so its metadata test asserts that
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.
This commit is contained in:
1 parent
915779b948
commit
6cec0cab24
1 file changed
+8
-4
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user