log rotate: only add .zst to new file after second rotation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-11-04 17:15:11 +01:00
parent 30200b5c4a
commit be99df2767
1 changed files with 2 additions and 2 deletions

View File

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