]> git.proxmox.com Git - proxmox-backup.git/commitdiff
log rotate: only add .zst to new file after second rotation
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 4 Nov 2020 16:15:11 +0000 (17:15 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 4 Nov 2020 16:16:55 +0000 (17:16 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/tools/logrotate.rs

index 86415e86ce256667bdc8e2a75d297a721eda5de8..c3195e2c1c1d2e31b66bf13a76c8175496da4e2b 100644 (file)
@@ -92,15 +92,15 @@ impl LogRotate {
         if filenames.is_empty() {
             return Ok(()); // no file means nothing to rotate
         }
+        let count = filenames.len() + 1;
 
         let mut next_filename = self.base_path.clone().canonicalize()?.into_os_string();
         next_filename.push(format!(".{}", filenames.len()));
-        if self.compress {
+        if self.compress && count > 2 {
             next_filename.push(".zst");
         }
 
         filenames.push(PathBuf::from(next_filename));
-        let count = filenames.len();
 
         for i in (0..count-1).rev() {
             if self.compress