Browse Source

delete file storage when POST to update

PUT is used to update. But sometimes POST is also used to post the same
file again. In this case, the actual file storage was not marked as
deleted.

This fix will try its best to delete the orphan files.
pull/312/head
Chris Lu 9 years ago
parent
commit
b456173eb8
  1. 8
      weed/server/filer_server_handlers_write.go

8
weed/server/filer_server_handlers_write.go

@ -139,6 +139,14 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
} }
// also delete the old fid unless PUT operation
if r.Method != "PUT" {
if oldFid, err := fs.filer.FindFile(path); err == nil {
operation.DeleteFile(fs.master, oldFid, fs.jwt(oldFid))
}
}
glog.V(4).Infoln("saving", path, "=>", fileId) glog.V(4).Infoln("saving", path, "=>", fileId)
if db_err := fs.filer.CreateFile(path, fileId); db_err != nil { if db_err := fs.filer.CreateFile(path, fileId); db_err != nil {
operation.DeleteFile(fs.master, fileId, fs.jwt(fileId)) //clean up operation.DeleteFile(fs.master, fileId, fs.jwt(fileId)) //clean up

Loading…
Cancel
Save