refactor(save): more idiomatic list_available_backup_user

This commit is contained in:
Rudxain 2025-04-19 16:22:20 -04:00
commit a7fd492f5a
No known key found for this signature in database
GPG key ID: 0DAC837DDEF8E96C

View file

@ -80,20 +80,16 @@ pub fn list_available_backups(dir: &Path) -> Vec<DisplayablePath> {
pub fn list_available_backup_user(backup: DisplayablePath) -> Vec<User> {
match fs::read_to_string(backup.path) {
Ok(data) => {
let phone_backup: PhoneBackup =
serde_json::from_str(&data).expect("Unable to parse backup file");
let mut users = vec![];
for u in phone_backup.users {
users.push(User {
id: u.id,
index: 0,
protected: false,
});
}
users
}
Ok(data) => serde_json::from_str::<PhoneBackup>(&data)
.expect("Unable to parse backup file")
.users
.into_iter()
.map(|u| User {
id: u.id,
index: 0,
protected: false,
})
.collect(),
Err(e) => {
error!("[BACKUP]: Selected backup file not found: {}", e);
vec![]