2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 03:18:55 +00:00

Restore does not truncate files it restores

Missing O_TRUNC when doing O_CREAT.

Closes #875
This commit is contained in:
Pauline Middelink 2017-03-10 22:45:26 +01:00
parent 8958efba60
commit b75186533d
3 changed files with 3 additions and 3 deletions

View File

@ -53,7 +53,7 @@ func initDebugLogger() {
}
if err != nil && os.IsNotExist(errors.Cause(err)) {
f, err = fs.OpenFile(debugfile, os.O_WRONLY|os.O_CREATE, 0600)
f, err = fs.OpenFile(debugfile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
}
if err != nil {

View File

@ -44,7 +44,7 @@ func loadIDSet(t testing.TB, filename string) restic.BlobSet {
}
func saveIDSet(t testing.TB, filename string, s restic.BlobSet) {
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0644)
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
t.Fatalf("unable to update golden file %v: %v", filename, err)
return

View File

@ -234,7 +234,7 @@ func (node Node) createFileAt(path string, repo Repository, idx *HardlinkIndex)
return nil
}
f, err := fs.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0600)
f, err := fs.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
defer f.Close()
if err != nil {