Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions code/crates/unwreck-restore/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion code/crates/unwreck-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
4 changes: 3 additions & 1 deletion code/crates/unwreck-store/src/perms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down Expand Up @@ -68,7 +70,7 @@ pub fn permission_warnings(root: &Path) -> Vec<String> {
#[cfg(not(unix))]
{
let _ = root;
return Vec::new();
Vec::new()
}
#[cfg(unix)]
{
Expand Down
Loading