Compare commits
No commits in common. "f71db90922a8eaa3758e569e763d8f999caec53d" and "bfd278abbe379e9c027b7ef4b6c9c0e268c29551" have entirely different histories.
f71db90922
...
bfd278abbe
|
|
@ -33,8 +33,6 @@ pub enum BackupType {
|
||||||
pub struct Backup<T: Clone> {
|
pub struct Backup<T: Clone> {
|
||||||
/// When the backup was started (also corresponds to the name)
|
/// When the backup was started (also corresponds to the name)
|
||||||
pub start_time: chrono::DateTime<Utc>,
|
pub start_time: chrono::DateTime<Utc>,
|
||||||
/// When the backup finished
|
|
||||||
pub end_time: chrono::DateTime<Utc>,
|
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
/// Type of the backup
|
/// Type of the backup
|
||||||
pub type_: BackupType,
|
pub type_: BackupType,
|
||||||
|
|
@ -119,7 +117,6 @@ impl<T: Clone> Backup<T> {
|
||||||
Ok(Backup {
|
Ok(Backup {
|
||||||
type_: BackupType::Full,
|
type_: BackupType::Full,
|
||||||
start_time,
|
start_time,
|
||||||
end_time: chrono::Utc::now(),
|
|
||||||
size: tar_gz.bytes_written(),
|
size: tar_gz.bytes_written(),
|
||||||
delta,
|
delta,
|
||||||
metadata: None,
|
metadata: None,
|
||||||
|
|
@ -177,7 +174,6 @@ impl<T: Clone> Backup<T> {
|
||||||
Ok(Backup {
|
Ok(Backup {
|
||||||
type_: BackupType::Incremental,
|
type_: BackupType::Incremental,
|
||||||
start_time,
|
start_time,
|
||||||
end_time: chrono::Utc::now(),
|
|
||||||
size: tar_gz.bytes_written(),
|
size: tar_gz.bytes_written(),
|
||||||
delta,
|
delta,
|
||||||
metadata: None,
|
metadata: None,
|
||||||
|
|
@ -239,17 +235,19 @@ impl<T: Clone> fmt::Display for Backup<T> {
|
||||||
// Pretty-print size
|
// Pretty-print size
|
||||||
// If your backup is a petabyte or larger, this will crash and you need to re-evaluate your
|
// If your backup is a petabyte or larger, this will crash and you need to re-evaluate your
|
||||||
// life choices
|
// life choices
|
||||||
let index = self.size.ilog(1024) as usize;
|
let mut index = 0;
|
||||||
let size = self.size as f64 / (1024.0_f64.powi(index as i32));
|
let mut size = self.size as f64;
|
||||||
let duration = self.end_time - self.start_time;
|
|
||||||
|
while size >= 1024.0 {
|
||||||
|
index += 1;
|
||||||
|
size /= 1024.0;
|
||||||
|
}
|
||||||
|
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{} ({}, {}m{}s, {:.2}{}, {})",
|
"{} ({}, {:.2}{}, {})",
|
||||||
self.start_time.format(Backup::FILENAME_FORMAT),
|
self.start_time.format(Backup::FILENAME_FORMAT),
|
||||||
letter,
|
letter,
|
||||||
duration.num_seconds() / 60,
|
|
||||||
duration.num_seconds() % 60,
|
|
||||||
size,
|
size,
|
||||||
BYTE_SUFFIXES[index],
|
BYTE_SUFFIXES[index],
|
||||||
self.delta
|
self.delta
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue