diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-07-20 02:14:18 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-07-20 02:14:18 -0700 |
| commit | 80d80daf64370d6a3d37afa6ce06258335ac856f (patch) | |
| tree | 2caffc9b550678719a2c90a1cc0015fde9d26908 /weed/server | |
| parent | dad733086a0bde2fa3c01d3e294ea3233ec73640 (diff) | |
| download | seaweedfs-80d80daf64370d6a3d37afa6ce06258335ac856f.tar.xz seaweedfs-80d80daf64370d6a3d37afa6ce06258335ac856f.zip | |
set filer2.ErrNotFound for not found entry
Diffstat (limited to 'weed/server')
| -rw-r--r-- | weed/server/filer_server_handlers_write.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/weed/server/filer_server_handlers_write.go b/weed/server/filer_server_handlers_write.go index 668f14ee8..0c278f67c 100644 --- a/weed/server/filer_server_handlers_write.go +++ b/weed/server/filer_server_handlers_write.go @@ -27,20 +27,26 @@ type FilerPostResult struct { func (fs *FilerServer) queryFileInfoByPath(w http.ResponseWriter, r *http.Request, path string) (fileId, urlLocation string, err error) { var entry *filer2.Entry - if entry, err = fs.filer.FindEntry(filer2.FullPath(path)); err != nil { + entry, err = fs.filer.FindEntry(filer2.FullPath(path)) + if err == filer2.ErrNotFound { + return "", "", nil + } + + if err != nil { glog.V(0).Infoln("failing to find path in filer store", path, err.Error()) writeJsonError(w, r, http.StatusInternalServerError, err) + return + } + + if len(entry.Chunks) == 0 { + glog.V(1).Infof("empty entry: %s", path) + w.WriteHeader(http.StatusNoContent) } else { - if len(entry.Chunks) == 0 { - glog.V(1).Infof("empty entry: %s", path) - w.WriteHeader(http.StatusNoContent) - }else{ - fileId = entry.Chunks[0].FileId - urlLocation, err = operation.LookupFileId(fs.filer.GetMaster(), fileId) - if err != nil { - glog.V(1).Infof("operation LookupFileId %s failed, err is %s", fileId, err.Error()) - w.WriteHeader(http.StatusNotFound) - } + fileId = entry.Chunks[0].FileId + urlLocation, err = operation.LookupFileId(fs.filer.GetMaster(), fileId) + if err != nil { + glog.V(1).Infof("operation LookupFileId %s failed, err is %s", fileId, err.Error()) + w.WriteHeader(http.StatusNotFound) } } return |
