aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-07-10 12:11:18 -0700
committerChris Lu <chris.lu@gmail.com>2019-07-10 12:11:18 -0700
commit476a7c269c402e24e531572939dedd57bd36ecde (patch)
treefb73620dee49056ab8eed030d44f1315c3d8a265
parent1e2127e2611f8942adf68355639a4b8f0309957f (diff)
downloadseaweedfs-476a7c269c402e24e531572939dedd57bd36ecde.tar.xz
seaweedfs-476a7c269c402e24e531572939dedd57bd36ecde.zip
detect a filer path is a file or a directory
fix https://github.com/chrislusf/seaweedfs/issues/1004
-rw-r--r--weed/server/filer_server_handlers_read.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go
index 62a896942..0edf501a8 100644
--- a/weed/server/filer_server_handlers_read.go
+++ b/weed/server/filer_server_handlers_read.go
@@ -21,7 +21,8 @@ import (
func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) {
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]
}
@@ -47,6 +48,11 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
return
}
+ if isForDirectory {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+
if len(entry.Chunks) == 0 {
glog.V(1).Infof("no file chunks for %s, attr=%+v", path, entry.Attr)
stats.FilerRequestCounter.WithLabelValues("read.nocontent").Inc()