diff --git a/CHANGELOG.md b/CHANGELOG.md index 969eb90..124ec26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed - Correct `pesde.toml` inclusion message in `publish` command by @daimond113 +- Allow writes to files when `link` is false in PackageFS::write_to by @daimond113 ## [0.5.0-rc.5] - 2024-10-12 ### Added diff --git a/src/source/fs.rs b/src/source/fs.rs index 6b04a0d..77f8aa4 100644 --- a/src/source/fs.rs +++ b/src/source/fs.rs @@ -160,7 +160,21 @@ impl PackageFS { if link { std::fs::hard_link(cas_file_path, path)?; } else { - std::fs::copy(cas_file_path, path)?; + let mut f = std::fs::File::create(&path)?; + f.write_all(&std::fs::read(cas_file_path)?)?; + + let mut permissions = f.metadata()?.permissions(); + #[cfg(windows)] + { + #[allow(clippy::permissions_set_readonly_false)] + permissions.set_readonly(false); + } + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + permissions.set_mode(permissions.mode() | 0o644); + } + f.set_permissions(permissions)?; } } FSEntry::Directory => {