Skip to content

Commit

Permalink
Merge pull request #74 from Kladki/copy-bootstrapped-permissions
Browse files Browse the repository at this point in the history
Copy file permissions when bootstrapping file content
  • Loading branch information
TheAlan404 authored Nov 12, 2024
2 parents bf6eddb + c5b5f45 commit cac6964
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/core/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,25 @@ impl<'a> BuildContext<'a> {
"Reading from '{}' ; [{pretty_path}]",
source.display()
))?;
let permissions = fs::metadata(&source)
.await
.context(format!(
"Getting metadata of '{}' ; [{pretty_path}]",
source.display()
))?
.permissions();

let bootstrapped_contents = self.bootstrap_content(&config_contents);

fs::write(&dest, bootstrapped_contents)
.await
.context(format!("Writing to '{}' ; [{pretty_path}]", dest.display()))?;
fs::set_permissions(&dest, permissions)
.await
.context(format!(
"Setting permissions for '{}' ; [{pretty_path}]",
dest.display()
))?;
} else {
// ? idk why but read_to_string and fs::write works with 'dest' but fs::copy doesnt
fs::copy(&source, &dest).await.context(format!(
Expand Down

0 comments on commit cac6964

Please sign in to comment.