mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
detect a filer path is a file or a directory
fix https://github.com/chrislusf/seaweedfs/issues/1004
This commit is contained in:
parent
1e2127e261
commit
476a7c269c
|
@ -21,7 +21,8 @@ import (
|
||||||
func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) {
|
func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) {
|
||||||
|
|
||||||
path := r.URL.Path
|
path := r.URL.Path
|
||||||
if strings.HasSuffix(path, "/") && len(path) > 1 {
|
isForDirectory := strings.HasSuffix(path, "/")
|
||||||
|
if isForDirectory && len(path) > 1 {
|
||||||
path = path[:len(path)-1]
|
path = path[:len(path)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +48,11 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isForDirectory {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(entry.Chunks) == 0 {
|
if len(entry.Chunks) == 0 {
|
||||||
glog.V(1).Infof("no file chunks for %s, attr=%+v", path, entry.Attr)
|
glog.V(1).Infof("no file chunks for %s, attr=%+v", path, entry.Attr)
|
||||||
stats.FilerRequestCounter.WithLabelValues("read.nocontent").Inc()
|
stats.FilerRequestCounter.WithLabelValues("read.nocontent").Inc()
|
||||||
|
|
Loading…
Reference in a new issue