Prefix temporary file with object id

This commit is contained in:
Michael Eischer 2021-08-12 22:17:49 +02:00
parent 28f569c0df
commit 64a43228de

View file

@ -553,7 +553,8 @@ func (h *Handler) saveBlob(w http.ResponseWriter, r *http.Request) {
return return
} }
tf, err := ioutil.TempFile(filepath.Dir(path), ".rest-server-temp") tmpFn := objectID + ".rest-server-temp"
tf, err := ioutil.TempFile(filepath.Dir(path), tmpFn)
if os.IsNotExist(err) { if os.IsNotExist(err) {
// the error is caused by a missing directory, create it and retry // the error is caused by a missing directory, create it and retry
mkdirErr := os.MkdirAll(filepath.Dir(path), h.opt.DirMode) mkdirErr := os.MkdirAll(filepath.Dir(path), h.opt.DirMode)
@ -561,7 +562,7 @@ func (h *Handler) saveBlob(w http.ResponseWriter, r *http.Request) {
log.Print(mkdirErr) log.Print(mkdirErr)
} else { } else {
// try again // try again
tf, err = ioutil.TempFile(filepath.Dir(path), ".rest-server-temp") tf, err = ioutil.TempFile(filepath.Dir(path), tmpFn)
} }
} }
if err != nil { if err != nil {