src/backup/datastore.rs: use unix epoch to create DateTime

To make sure that we have a timestamp without nanosecond.
This commit is contained in:
Dietmar Maurer
2019-03-04 17:58:22 +01:00
parent 38f8815925
commit 875fb1c01a
4 changed files with 11 additions and 14 deletions

View File

@ -110,9 +110,8 @@ fn list_backups(
let id = item["backup-id"].as_str().unwrap();
let btype = item["backup-type"].as_str().unwrap();
let epoch = item["backup-time"].as_i64().unwrap();
let backup_time = Local.timestamp(epoch, 0);
let backup_dir = BackupDir::new(BackupGroup::new(btype, id), backup_time);
let backup_dir = BackupDir::new(BackupGroup::new(btype, id), epoch);
let files = item["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_owned()).collect();
@ -120,7 +119,7 @@ fn list_backups(
for filename in info.files {
let path = info.backup_dir.relative_path().to_str().unwrap().to_owned();
println!("{} | {}/{}", backup_time.format("%c"), path, filename);
println!("{} | {}/{}", info.backup_dir.backup_time().format("%c"), path, filename);
}
}
@ -203,9 +202,8 @@ fn list_snapshots(
let id = item["backup-id"].as_str().unwrap();
let btype = item["backup-type"].as_str().unwrap();
let epoch = item["backup-time"].as_i64().unwrap();
let backup_time = Local.timestamp(epoch, 0);
let snapshot = BackupDir::new(BackupGroup::new(btype, id), backup_time);
let snapshot = BackupDir::new(BackupGroup::new(btype, id), epoch);
let path = snapshot.relative_path().to_str().unwrap().to_owned();
@ -214,7 +212,7 @@ fn list_snapshots(
v.as_str().unwrap().to_owned()
}).collect();
println!("{} | {} | {}", path, backup_time.format("%c"), tools::join(&files, ' '));
println!("{} | {} | {}", path, snapshot.backup_time().format("%c"), tools::join(&files, ' '));
}
Ok(Value::Null)