avoid using empty fileId to delete

fix https://github.com/chrislusf/seaweedfs/issues/183
This commit is contained in:
chrislusf 2015-08-21 14:09:33 -07:00
parent 1c6729d4c1
commit 91db227b27
2 changed files with 4 additions and 1 deletions

View file

@ -43,6 +43,9 @@ func (fl *FileListInLevelDb) CreateFile(dirId filer.DirectoryId, fileName string
}
func (fl *FileListInLevelDb) DeleteFile(dirId filer.DirectoryId, fileName string) (fid string, err error) {
if fid, err = fl.FindFile(dirId, fileName); err != nil {
if err == leveldb.ErrNotFound {
return "", nil
}
return
}
err = fl.db.Delete(genKey(dirId, fileName), nil)

View file

@ -209,7 +209,7 @@ func (fs *FilerServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
err = fs.filer.DeleteDirectory(r.URL.Path, isRecursive)
} else {
fid, err = fs.filer.DeleteFile(r.URL.Path)
if err == nil {
if err == nil && fid != "" {
err = operation.DeleteFile(fs.master, fid, fs.jwt(fid))
}
}