mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 11:47:56 +08: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:
@@ -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
|
||||
|
Reference in New Issue
Block a user