From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 497E263297 for ; Fri, 2 Oct 2020 15:20:42 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 356E7A741 for ; Fri, 2 Oct 2020 15:20:12 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id ABB1EA739 for ; Fri, 2 Oct 2020 15:20:11 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6FEF1445FC for ; Fri, 2 Oct 2020 15:20:11 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 2 Oct 2020 15:20:10 +0200 Message-Id: <20201002132010.3691-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.537 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup] task archive rotation: better handle non-existing archive X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2020 13:20:42 -0000 if the archive file does not exist yet, we cannot rotate it, but it's not actually an error, so just return Ok(false) to indicate no rotation took place Signed-off-by: Dominik Csapak --- src/server/worker_task.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs index b2e2abd5..409e7b49 100644 --- a/src/server/worker_task.rs +++ b/src/server/worker_task.rs @@ -345,7 +345,12 @@ fn lock_task_list_files(exclusive: bool) -> Result { pub fn rotate_task_log_archive(size_threshold: u64, compress: bool, max_files: Option) -> Result { let _lock = lock_task_list_files(true)?; let path = Path::new(PROXMOX_BACKUP_ARCHIVE_TASK_FN); - let metadata = path.metadata()?; + let metadata = match path.metadata() { + Ok(metadata) => metadata, + Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(false), + Err(err) => bail!("unable to open task archive - {}", err), + }; + if metadata.len() > size_threshold { let mut logrotate = LogRotate::new(PROXMOX_BACKUP_ARCHIVE_TASK_FN, compress).ok_or_else(|| format_err!("could not get archive file names"))?; let backup_user = crate::backup::backup_user()?; -- 2.20.1