add Display trait to BackupDir

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-06-19 08:05:09 +02:00 committed by Dietmar Maurer
parent 3b62116ce6
commit abdb976340
2 changed files with 10 additions and 3 deletions

View File

@ -1,7 +1,6 @@
use std::collections::{HashSet, HashMap};
use std::convert::TryFrom;
use chrono::{TimeZone, Local};
use anyhow::{bail, Error};
use futures::*;
use hyper::http::request::Parts;
@ -748,8 +747,7 @@ fn download_file(
let allowed = (user_privs & PRIV_DATASTORE_READ) != 0;
if !allowed { check_backup_owner(&datastore, backup_dir.group(), &username)?; }
println!("Download {} from {} ({}/{}/{}/{})", file_name, store,
backup_type, backup_id, Local.timestamp(backup_time, 0), file_name);
println!("Download {} from {} ({}/{})", file_name, store, backup_dir, file_name);
let mut path = datastore.base_path();
path.push(backup_dir.relative_path());

View File

@ -212,6 +212,15 @@ impl BackupDir {
}
}
impl std::fmt::Display for BackupDir {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let backup_type = self.group.backup_type();
let id = self.group.backup_id();
let time = Self::backup_time_to_string(self.backup_time);
write!(f, "{}/{}/{}", backup_type, id, time)
}
}
impl From<(BackupGroup, i64)> for BackupDir {
fn from((group, timestamp): (BackupGroup, i64)) -> Self {
Self { group, backup_time: Utc.timestamp(timestamp, 0) }