]> git.proxmox.com Git - proxmox-backup.git/commitdiff
partially revert commit 1f82f9b7b5d231da22a541432d5617cb303c0000
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 29 Jun 2020 10:44:45 +0000 (12:44 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 29 Jun 2020 10:44:45 +0000 (12:44 +0200)
do it backwards compatible. Also, code was wrong because FixedIndexWriter
still computed old style csums...

src/backup/dynamic_index.rs
src/backup/fixed_index.rs
src/backup/index.rs

index 8b9694f41e4b802ff41be521963a2abca5b11a33..4907fe1f88e12580e5ec8c05f0be25be6581e0ab 100644 (file)
@@ -189,6 +189,19 @@ impl IndexFile for DynamicIndexReader {
         }
     }
 
+    fn compute_csum(&self) -> ([u8; 32], u64) {
+        let mut csum = openssl::sha::Sha256::new();
+        let mut chunk_end = 0;
+        for pos in 0..self.index_count() {
+            let info = self.chunk_info(pos).unwrap();
+            chunk_end = info.range.end;
+            csum.update(&chunk_end.to_le_bytes());
+            csum.update(&info.digest);
+        }
+        let csum = csum.finish();
+        (csum, chunk_end)
+    }
+
     #[allow(clippy::cast_ptr_alignment)]
     fn chunk_info(&self, pos: usize) -> Option<ChunkReadInfo> {
         if pos >= self.index.len() {
index c92bdff9693abfd0c1a97db4799ad8e07d5108e8..73d0dad0f788da43ca728073e20baccff22514cd 100644 (file)
@@ -206,6 +206,19 @@ impl IndexFile for FixedIndexReader {
             digest: *digest,
         })
     }
+
+    fn compute_csum(&self) -> ([u8; 32], u64) {
+        let mut csum = openssl::sha::Sha256::new();
+        let mut chunk_end = 0;
+        for pos in 0..self.index_count() {
+            let info = self.chunk_info(pos).unwrap();
+            chunk_end = info.range.end;
+            csum.update(&info.digest);
+        }
+        let csum = csum.finish();
+
+        (csum, chunk_end)
+    }
 }
 
 pub struct FixedIndexWriter {
index d61a477ccb7a12569f329c34ac2b61f0d2cc69ce..efdf3b5408b7b616a76b9531e37871f5331efbf2 100644 (file)
@@ -23,19 +23,7 @@ pub trait IndexFile {
     fn chunk_info(&self, pos: usize) -> Option<ChunkReadInfo>;
 
     /// Compute index checksum and size
-    fn compute_csum(&self) -> ([u8; 32], u64) {
-        let mut csum = openssl::sha::Sha256::new();
-        let mut chunk_end = 0;
-        for pos in 0..self.index_count() {
-            let info = self.chunk_info(pos).unwrap();
-            chunk_end = info.range.end;
-            csum.update(&chunk_end.to_le_bytes());
-            csum.update(&info.digest);
-        }
-        let csum = csum.finish();
-
-        (csum, chunk_end)
-    }
+    fn compute_csum(&self) -> ([u8; 32], u64);
 
     /// Returns most often used chunks
     fn find_most_used_chunks(&self, max: usize) -> HashMap<[u8; 32], usize> {