mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
parent
b786c5d1cc
commit
f02ee7386a
2 changed files with 11 additions and 4 deletions
11
handlers.go
11
handlers.go
|
@ -367,6 +367,17 @@ func SaveBlob(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
tf, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0600)
|
||||
if os.IsNotExist(err) {
|
||||
// the error is caused by a missing directory, create it and retry
|
||||
mkdirErr := os.MkdirAll(filepath.Dir(path), 0700)
|
||||
if mkdirErr != nil {
|
||||
log.Print(mkdirErr)
|
||||
} else {
|
||||
// try again
|
||||
tf, err = os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0600)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if Config.Debug {
|
||||
log.Print(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue