Skip to content

Commit

Permalink
modify error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
t-aleksander committed Jan 16, 2025
1 parent 5d8b48f commit 2f36386
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src-tauri/cli/src/bin/dg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,20 @@ impl CliConfig {
};
#[cfg(not(windows))]
{
let mut perms = file
.metadata()
.map_err(|err| {
CliError::ConfigSave(path.to_string_lossy().to_string(), err.to_string())
})?
.permissions();
perms.set_mode(0o600);
file.set_permissions(perms).map_err(|err| {
CliError::ConfigSave(path.to_string_lossy().to_string(), err.to_string())
})?;
debug!("Setting config file permissions...");
match file.metadata() {
Ok(meta) => {
let mut perms = meta.permissions();
perms.set_mode(0o600);
if let Err(err) = file.set_permissions(perms) {
warn!("Failed to set permissions for the configuration file: {err}");
}
}
Err(err) => {
warn!("Failed to set permissions for the configuration file: {err}")
}
}
debug!("Config file permissions have been set.");
}
match serde_json::to_writer(file, &self) {
Ok(()) => debug!(
Expand Down

0 comments on commit 2f36386

Please sign in to comment.