diff --git a/code/crates/unwreck-restore/src/io.rs b/code/crates/unwreck-restore/src/io.rs index 6cdd49c..1eb0c76 100644 --- a/code/crates/unwreck-restore/src/io.rs +++ b/code/crates/unwreck-restore/src/io.rs @@ -61,6 +61,8 @@ pub(crate) fn make_writable(p: &Path) { { let mut perm = meta.permissions(); if perm.readonly() { + // On Windows, clearing the read-only attribute is the supported way to make the file writable. + #[allow(clippy::permissions_set_readonly_false)] perm.set_readonly(false); let _ = fs::set_permissions(p, perm); } diff --git a/code/crates/unwreck-store/src/lib.rs b/code/crates/unwreck-store/src/lib.rs index c4e94dc..720ec8b 100644 --- a/code/crates/unwreck-store/src/lib.rs +++ b/code/crates/unwreck-store/src/lib.rs @@ -340,7 +340,8 @@ impl Store { } let mut dirs = HashSet::new(); for (tmp, dest, h) in batch.loose { - File::open(&tmp)?.sync_all()?; + // Windows requires a write-capable handle for FlushFileBuffers (sync_all). + fs::OpenOptions::new().write(true).open(&tmp)?.sync_all()?; let parent = dest.parent().expect("object has parent").to_path_buf(); ensure_private_dir(&parent)?; fs::rename(&tmp, &dest)?; diff --git a/code/crates/unwreck-store/src/perms.rs b/code/crates/unwreck-store/src/perms.rs index a669802..c9e9d81 100644 --- a/code/crates/unwreck-store/src/perms.rs +++ b/code/crates/unwreck-store/src/perms.rs @@ -6,7 +6,9 @@ use std::path::Path; #[cfg(unix)] use std::os::unix::fs::{OpenOptionsExt, PermissionsExt}; +#[cfg(unix)] const DIR_MODE: u32 = 0o700; +#[cfg(unix)] const FILE_MODE: u32 = 0o600; pub(crate) fn ensure_private_dir(p: &Path) -> io::Result<()> { @@ -68,7 +70,7 @@ pub fn permission_warnings(root: &Path) -> Vec { #[cfg(not(unix))] { let _ = root; - return Vec::new(); + Vec::new() } #[cfg(unix)] {