src/backup/datastore.rs: use new() function to create structs
This commit is contained in:
parent
9b492eb256
commit
38f8815925
@ -101,14 +101,9 @@ impl BackupDir {
|
|||||||
let cap = SNAPSHOT_PATH_REGEX.captures(path)
|
let cap = SNAPSHOT_PATH_REGEX.captures(path)
|
||||||
.ok_or_else(|| format_err!("unable to parse backup snapshot path '{}'", path))?;
|
.ok_or_else(|| format_err!("unable to parse backup snapshot path '{}'", path))?;
|
||||||
|
|
||||||
|
let group = BackupGroup::new(cap.get(1).unwrap().as_str(), cap.get(2).unwrap().as_str());
|
||||||
Ok(Self {
|
let backup_time = cap.get(3).unwrap().as_str().parse::<DateTime<Local>>()?;
|
||||||
group: BackupGroup {
|
Ok(BackupDir::new(group, backup_time))
|
||||||
backup_type: cap.get(1).unwrap().as_str().to_owned(),
|
|
||||||
backup_id: cap.get(2).unwrap().as_str().to_owned(),
|
|
||||||
},
|
|
||||||
backup_time: cap.get(3).unwrap().as_str().parse::<DateTime<Local>>()?,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn backup_time_to_file_name(backup_time: DateTime<Local>) -> String {
|
fn backup_time_to_file_name(backup_time: DateTime<Local>) -> String {
|
||||||
@ -337,13 +332,7 @@ impl DataStore {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
list.push(BackupInfo {
|
list.push(BackupInfo {
|
||||||
backup_dir: BackupDir {
|
backup_dir: BackupDir::new(BackupGroup::new(backup_type, backup_id), dt),
|
||||||
group: BackupGroup {
|
|
||||||
backup_type: backup_type.to_owned(),
|
|
||||||
backup_id: backup_id.to_owned(),
|
|
||||||
},
|
|
||||||
backup_time: dt,
|
|
||||||
},
|
|
||||||
files,
|
files,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user