mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
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.
This commit is contained in:
parent
535b1610c8
commit
b456173eb8
|
@ -139,6 +139,14 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||
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)
|
||||
if db_err := fs.filer.CreateFile(path, fileId); db_err != nil {
|
||||
operation.DeleteFile(fs.master, fileId, fs.jwt(fileId)) //clean up
|
||||
|
|
Loading…
Reference in a new issue