fix: allow writes to copied cas files

This commit is contained in:
daimond113 2024-10-13 13:57:55 +02:00
parent bf77b69b0b
commit e6773144db
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 16 additions and 1 deletions

View file

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed ### Fixed
- Correct `pesde.toml` inclusion message in `publish` command by @daimond113 - 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 ## [0.5.0-rc.5] - 2024-10-12
### Added ### Added

View file

@ -160,7 +160,21 @@ impl PackageFS {
if link { if link {
std::fs::hard_link(cas_file_path, path)?; std::fs::hard_link(cas_file_path, path)?;
} else { } 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 => { FSEntry::Directory => {