Backup::date -> timestamp

pull/10/head
Dennis Schwerdel 5 years ago
parent afef4004bd
commit fabfb1dce5
  1. 1
      CHANGELOG.md
  2. 6
      src/cli/mod.rs
  3. 6
      src/repository/backup.rs
  4. 4
      src/repository/backup_file.rs
  5. 2
      src/repository/mod.rs
  6. 2
      src/repository/tarfile.rs

@ -5,6 +5,7 @@ This project follows [semantic versioning](http://semver.org).
### UNRELEASED
* [added] Ability to read/write tar file from/to stdin/stdout
* [added] Added date to bundles
* [modified] Logging to stderr
* [fixed] Only print "repairing bundles" if actually repairing bundles

@ -127,7 +127,7 @@ fn find_reference_backup(repo: &Repository, path: &str) -> Result<Option<(String
matching.push((name, backup));
}
}
matching.sort_by_key(|&(_, ref b)| b.date);
matching.sort_by_key(|&(_, ref b)| b.timestamp);
Ok(matching.pop())
}
@ -135,7 +135,7 @@ fn print_backup(backup: &Backup) {
if backup.modified {
warn!("This backup has been modified");
}
println!("Date: {}", Local.timestamp(backup.date, 0).to_rfc2822());
println!("Date: {}", Local.timestamp(backup.timestamp, 0).to_rfc2822());
println!("Source: {}:{}", backup.host, backup.path);
println!("Duration: {}", to_duration(backup.duration));
println!("Entries: {} files, {} dirs", backup.file_count, backup.dir_count);
@ -193,7 +193,7 @@ fn print_backups(backup_map: &HashMap<String, Backup>) {
backups.sort_by_key(|b| b.0);
for (name, backup) in backups {
println!("{:40} {:>32} {:7} files, {:6} dirs, {:>10}",
name, Local.timestamp(backup.date, 0).to_rfc2822(), backup.file_count,
name, Local.timestamp(backup.timestamp, 0).to_rfc2822(), backup.file_count,
backup.dir_count, to_file_size(backup.total_data_size));
}
}

@ -89,11 +89,11 @@ impl Repository {
};
for (name, backup) in backup_map {
if name.starts_with(prefix) {
let date = Local.timestamp(backup.date, 0);
let date = Local.timestamp(backup.timestamp, 0);
backups.push((name, date, backup));
}
}
backups.sort_by_key(|backup| -backup.2.date);
backups.sort_by_key(|backup| -backup.2.timestamp);
let mut keep = Bitmap::new(backups.len());
fn mark_needed<K: Eq, F: Fn(&DateTime<Local>) -> K>(backups: &[(String, DateTime<Local>, Backup)], keep: &mut Bitmap, max: usize, keyfn: F) {
@ -275,7 +275,7 @@ impl Repository {
backup.root = try!(self.put_inode(&root_inode));
try!(self.flush());
let elapsed = Local::now().signed_duration_since(start);
backup.date = start.timestamp();
backup.timestamp = start.timestamp();
backup.total_data_size = root_inode.cum_size;
for &(_, len) in backup.root.iter() {
backup.total_data_size += len as u64;

@ -81,7 +81,7 @@ pub struct Backup {
pub bundle_count: usize,
pub chunk_count: usize,
pub avg_chunk_size: f32,
pub date: i64,
pub timestamp: i64,
pub duration: f32,
pub file_count: usize,
pub dir_count: usize,
@ -101,7 +101,7 @@ serde_impl!(Backup(u8?) {
bundle_count: usize => 5,
chunk_count: usize => 6,
avg_chunk_size: f32 => 7,
date: i64 => 8,
timestamp: i64 => 8,
duration: f32 => 9,
file_count: usize => 10,
dir_count: usize => 11,

@ -164,7 +164,7 @@ impl Repository {
}
repo = try!(Repository::open(path));
let mut backups: Vec<(String, Backup)> = try!(repo.get_all_backups()).into_iter().collect();
backups.sort_by_key(|&(_, ref b)| b.date);
backups.sort_by_key(|&(_, ref b)| b.timestamp);
if let Some((name, backup)) = backups.pop() {
info!("Taking configuration from the last backup '{}'", name);
repo.config = backup.config;

@ -194,7 +194,7 @@ impl Repository {
backup.root = chunks;
try!(self.flush());
let elapsed = Local::now().signed_duration_since(start);
backup.date = start.timestamp();
backup.timestamp = start.timestamp();
backup.total_data_size = root_inode.cum_size;
backup.file_count = root_inode.cum_files;
backup.dir_count = root_inode.cum_dirs;

Loading…
Cancel
Save