From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 3AE3A1FF173
	for <inbox@lore.proxmox.com>; Mon, 27 Jan 2025 13:28:12 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 5D0772A0E1;
	Mon, 27 Jan 2025 13:28:11 +0100 (CET)
Date: Mon, 27 Jan 2025 13:27:35 +0100
From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion <pbs-devel@lists.proxmox.com>
References: <20250127121016.247973-1-m.sandoval@proxmox.com>
In-Reply-To: <20250127121016.247973-1-m.sandoval@proxmox.com>
MIME-Version: 1.0
User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid)
Message-Id: <1737980596.kue4kgi0fu.astroid@yuna.none>
X-SPAM-LEVEL: Spam detection results:  1
 AWL 0.001 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.111.153, 185.199.108.153, 185.199.110.153, 185.199.109.153]
Subject: [pbs-devel] applied: [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
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

On January 27, 2025 1:10 pm, Maximiliano Sandoval wrote:
> 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 <m.sandoval@proxmox.com>
> ---
> 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<R: pxar::decoder::SeqRead>(
>              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
> 
> 
> 


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel