From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 554631FF173 for ; Mon, 27 Jan 2025 13:10:52 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CD48129482; Mon, 27 Jan 2025 13:10:50 +0100 (CET) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Mon, 27 Jan 2025 13:10:14 +0100 Message-Id: <20250127121016.247973-1-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 1 AWL 0.057 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy FSL_BULK_SIG 0.001 Bulk signature with no Unsubscribe KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RAZOR2_CF_RANGE_51_100 1.886 Razor2 gives confidence level above 50% RAZOR2_CHECK 0.922 Listed in Razor2 (http://razor.sf.net/) RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [185.199.109.153, 185.199.110.153, 185.199.108.153, 185.199.111.153] Subject: [pbs-devel] [PATCH backup v3 1/3] use truncate whenever we create files 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Fixes the suspicious_open_options clippy lint, for example: ``` warning: file opened with `create`, but `truncate` behavior not defined --> src/api2/tape/restore.rs:1713:18 | 1713 | .create(true) | ^^^^^^^^^^^^- help: add: `.truncate(true)` | = help: if you intend to overwrite an existing file entirely, call `.truncate(true)` = help: if you instead know that you may want to keep some parts of the old file, call `.truncate(false)` = help: alternatively, use `.append(true)` to append to the file instead of overwriting it = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_open_options ``` Signed-off-by: Maximiliano Sandoval --- Differences from v1: - Follow overwrite_flags in pxar extract src/api2/tape/restore.rs | 1 + src/server/sync.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs index 93a6053b..2cc1baab 100644 --- a/src/api2/tape/restore.rs +++ b/src/api2/tape/restore.rs @@ -1711,6 +1711,7 @@ fn try_restore_snapshot_archive( let mut tmpfile = std::fs::OpenOptions::new() .write(true) .create(true) + .truncate(true) .read(true) .open(&tmp_path) .map_err(|err| format_err!("restore {:?} failed - {}", tmp_path, err))?; diff --git a/src/server/sync.rs b/src/server/sync.rs index 5e3fbdcd..4dd46c5a 100644 --- a/src/server/sync.rs +++ b/src/server/sync.rs @@ -159,6 +159,7 @@ impl SyncSourceReader for RemoteSourceReader { let tmpfile = std::fs::OpenOptions::new() .write(true) .create(true) + .truncate(true) .read(true) .open(&tmp_path)?; -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel