Merge pull request #115 from rustic-rs/local-be-truncate

local backend: truncate file to correct length (if it exists)
This commit is contained in:
aawsome 2022-08-08 20:02:48 +02:00 committed by GitHub
commit effd7240bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,6 +144,7 @@ impl WriteBackend for LocalBackend {
.create(true)
.write(true)
.open(&filename)?;
file.set_len(0)?;
copy(&mut f, &mut file)?;
file.sync_all()?;
Ok(())
@ -156,6 +157,7 @@ impl WriteBackend for LocalBackend {
.create(true)
.write(true)
.open(&filename)?;
file.set_len(buf.len().try_into()?)?;
file.write_all(&buf)?;
file.sync_all()?;
Ok(())