From be99df2767d2e88678f999c1037fd5086d54d246 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 4 Nov 2020 17:15:11 +0100 Subject: [PATCH] log rotate: only add .zst to new file after second rotation Signed-off-by: Thomas Lamprecht --- src/tools/logrotate.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/logrotate.rs b/src/tools/logrotate.rs index 86415e86..c3195e2c 100644 --- a/src/tools/logrotate.rs +++ b/src/tools/logrotate.rs @@ -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