Skip to content

Commit

Permalink
fix: copy permissions when reflinking files (#1111)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Oct 11, 2024
1 parent e50dc78 commit 43dfa76
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/source/copy_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,18 @@ where
}

// Reflink or copy the file
reflink_copy::reflink_or_copy(from, to)?;
match reflink_copy::reflink_or_copy(from, &to)? {
None => {
// File has been reflinked, on Linux we need to copy the permissions
#[cfg(target_os = "linux")]
{
let metadata = fs_err::metadata(from)?;
let permissions = metadata.permissions();
fs_err::set_permissions(to, permissions)?;
}
}
Some(_) => {}
}

Ok(())
}
Expand Down

0 comments on commit 43dfa76

Please sign in to comment.