Skip to content

Commit

Permalink
handle non-existing file case on upload
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Dec 24, 2019
1 parent a3007ae commit 2d26f89
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions filereceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func saveFile(path string, offset int64, length int64, r io.Reader, log log.Logg
}
}
f, err := os.OpenFile(path, os.O_WRONLY, 0600)
if os.IsNotExist(err) {
_ = DeleteFileInfo(path)
return 0, nil, &OffsetMismatchError{offset, 0}
}
if err != nil {
return 0, nil, err
}
Expand Down

0 comments on commit 2d26f89

Please sign in to comment.