Skip to content

Commit

Permalink
chg: improve backup/restore error messages
Browse files Browse the repository at this point in the history
- Remove duplicated text
- Update error message when trying to restore a backup when the phone is not connected
- Add the backup name in the error message when trying to restore a deleted backup
  • Loading branch information
0x192 committed Jan 14, 2023
1 parent ae5e253 commit 49712b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/core/save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ pub async fn backup_phone(
Err(err) => Err(err.to_string()),
}
}
Err(err) => {
error!("[BACKUP]: {}", err);
Err(err.to_string())
}
Err(err) => Err(err.to_string()),
}
}

Expand Down Expand Up @@ -173,6 +170,6 @@ pub fn restore_backup(
}
Ok(commands)
}
Err(e) => Err("[BACKUP]: ".to_owned() + &e.to_string()),
Err(e) => Err(e.to_string()),
}
}
14 changes: 9 additions & 5 deletions src/gui/views/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::core::config::{BackupSettings, Config, DeviceSettings, GeneralSetting
use crate::core::save::{
backup_phone, list_available_backup_user, list_available_backups, restore_backup, BACKUP_DIR,
};
use crate::core::sync::{perform_adb_commands, CommandType, Phone};
use crate::core::sync::{get_android_sdk, perform_adb_commands, CommandType, Phone};
use crate::core::theme::Theme;
use crate::core::utils::{open_url, string_to_theme, unavailable_users, DisplayablePath};
use crate::gui::style;
Expand Down Expand Up @@ -158,8 +158,12 @@ impl Settings {
}
}
if r_packages.is_empty() {
self.device.backup.backup_state =
"Device state is already restored".to_string();
if get_android_sdk() == 0 {
self.device.backup.backup_state = "Device is not connected".to_string();
} else {
self.device.backup.backup_state =
"Device state is already restored".to_string();
}
}
info!(
"[RESTORE] Restoring backup {}",
Expand All @@ -168,8 +172,8 @@ impl Settings {
Command::batch(commands)
}
Err(e) => {
self.device.backup.backup_state = format!("ERROR: {e}");
error!("[BACKUP] {}", e);
self.device.backup.backup_state = e.to_string();
error!("{} - {}", self.device.backup.selected.as_ref().unwrap(), e);
Command::none()
}
},
Expand Down

0 comments on commit 49712b0

Please sign in to comment.