mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-10-04 22:02:47 +00:00
use truncate whenever we create files
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>
This commit is contained in:
parent
1cf52c6bb3
commit
600ce36d57
@ -1711,6 +1711,7 @@ fn try_restore_snapshot_archive<R: pxar::decoder::SeqRead>(
|
|||||||
let mut tmpfile = std::fs::OpenOptions::new()
|
let mut tmpfile = std::fs::OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
.read(true)
|
.read(true)
|
||||||
.open(&tmp_path)
|
.open(&tmp_path)
|
||||||
.map_err(|err| format_err!("restore {:?} failed - {}", tmp_path, err))?;
|
.map_err(|err| format_err!("restore {:?} failed - {}", tmp_path, err))?;
|
||||||
|
@ -159,6 +159,7 @@ impl SyncSourceReader for RemoteSourceReader {
|
|||||||
let tmpfile = std::fs::OpenOptions::new()
|
let tmpfile = std::fs::OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
.read(true)
|
.read(true)
|
||||||
.open(&tmp_path)?;
|
.open(&tmp_path)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user