]> git.proxmox.com Git - proxmox-backup.git/commitdiff
src/bin/proxmox-backup-client.rs: strip .didx file extensions
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 11 Mar 2019 09:51:48 +0000 (10:51 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 11 Mar 2019 09:54:02 +0000 (10:54 +0100)
src/backup/fixed_index.rs
src/bin/proxmox-backup-client.rs

index 064c54af063855c3e17e3e1a2d036da224287463..c8880ab76f4a981a57b75ed2eb8abab8178c195c 100644 (file)
@@ -12,7 +12,7 @@ use std::os::unix::io::AsRawFd;
 use uuid::Uuid;
 use chrono::{Local, TimeZone};
 
-/// Header format definition for fixed index files (`.fixd`)
+/// Header format definition for fixed index files (`.fidx`)
 #[repr(C)]
 pub struct FixedIndexHeader {
     /// The string `PROXMOX-FIDX`
index 36886cb234c4f9b804c3da2d180eb7b199fe0443..ed50c0c8c8ee869ace402346de00f677fd9d1338 100644 (file)
@@ -90,6 +90,23 @@ fn backup_image(datastore: &DataStore, file: &std::fs::File, size: usize, target
 }
 */
 
+fn strip_chunked_file_expenstions(list: Vec<String>) -> Vec<String> {
+
+    let mut result = vec![];
+
+    for file in list.into_iter() {
+        if file.ends_with(".didx") {
+            result.push(file[..file.len()-5].to_owned());
+        } else if file.ends_with(".fidx") {
+            result.push(file[..file.len()-5].to_owned());
+        } else {
+            result.push(file); // should not happen
+        }
+    }
+
+    result
+}
+
 fn list_backups(
     param: Value,
     _info: &ApiMethod,
@@ -117,12 +134,11 @@ fn list_backups(
         let backup_dir = BackupDir::new(btype, id, epoch);
 
         let files = item["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_owned()).collect();
+        let files = strip_chunked_file_expenstions(files);
 
-        let info = BackupInfo { backup_dir, files };
-
-        for filename in info.files {
-            let path = info.backup_dir.relative_path().to_str().unwrap().to_owned();
-            println!("{} | {}/{}", info.backup_dir.backup_time().format("%c"), path, filename);
+        for filename in files {
+            let path = backup_dir.relative_path().to_str().unwrap().to_owned();
+            println!("{} | {}/{}", backup_dir.backup_time().format("%c"), path, filename);
         }
     }
 
@@ -174,10 +190,8 @@ fn list_backup_groups(
 
         let path = group.group_path().to_str().unwrap().to_owned();
 
-        let files = item["files"].as_array().unwrap().iter()
-            .map(|v| {
-                v.as_str().unwrap().to_owned()
-            }).collect();
+        let files = item["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_owned()).collect();
+        let files = strip_chunked_file_expenstions(files);
 
         println!("{:20} | {} | {:5} | {}", path, last_backup.format("%c"),
                  backup_count, tools::join(&files, ' '));
@@ -224,10 +238,8 @@ fn list_snapshots(
 
         let path = snapshot.relative_path().to_str().unwrap().to_owned();
 
-        let files = item["files"].as_array().unwrap().iter()
-            .map(|v| {
-                v.as_str().unwrap().to_owned()
-            }).collect();
+        let files = item["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_owned()).collect();
+        let files = strip_chunked_file_expenstions(files);
 
         println!("{} | {} | {}", path, snapshot.backup_time().format("%c"), tools::join(&files, ' '));
     }