Skip to content

Commit

Permalink
fix user env
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaro17f committed Oct 1, 2023
1 parent ffb2a7f commit 67b6be3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wrestic"
version = "1.2.6"
version = "1.2.7"
authors = ["alvaro17f"]
description = "Restic wrapper built in Rust"
homepage = "https://github.com/alvaro17f/wrestic"
Expand Down
7 changes: 6 additions & 1 deletion src/modules/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fn do_restore(
repository: &str,
restore_folder: &str,
restore_snapshot: &str,
user: &str,
) -> Result<()> {
if run_cmd!(
restic -r $backend:$repository --verbose --verbose restore $restore_snapshot --target $restore_folder;
Expand All @@ -25,6 +26,9 @@ fn do_restore(
{
cprintln!("<r>Failed to restore snapshot: <c>{restore_snapshot}</c> into: <c>{restore_folder}</c></r>");
}
if run_cmd!(chown -R $user:$user $restore_folder).is_err() {
cprintln!("<r>Failed to change ownership of: <c>{restore_folder}</c></r>");
}

Ok(())
}
Expand Down Expand Up @@ -58,6 +62,7 @@ pub fn restore(noconfirm: bool) -> Result<()> {
let repository = &settings[selection].repository;
let restore_folder = &settings[selection].restore_folder;
let restore_snapshot = snapshots_selector(backend, repository)?;
let user = &settings[selection].user;

if Confirm::with_theme(&ColorfulTheme::default())
.with_prompt(cformat!(
Expand All @@ -66,7 +71,7 @@ pub fn restore(noconfirm: bool) -> Result<()> {
.default(true)
.interact()?
{
do_restore(backend, repository, restore_folder, &restore_snapshot)?;
do_restore(backend, repository, restore_folder, &restore_snapshot, user)?;
pause()?;
}
if !noconfirm {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/get_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub fn get_config() -> Result<Vec<Settings>> {
.build()?;

let user = find_config_file()
.unwrap()
.iter()
.nth(2)
.and_then(|f| f.to_str())
Expand All @@ -87,7 +88,7 @@ pub fn get_config() -> Result<Vec<Settings>> {
let deserialized_value = value.clone().try_deserialize::<serde_json::Value>()?;

let settings_struct = Settings {
user: user.clone(),
user: user.clone().replace('\"', ""),
name: key.to_string().replace('\"', ""),

backend: deserialized_value
Expand Down

0 comments on commit 67b6be3

Please sign in to comment.