Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

detect a filer path is a file or a directory

Chris Lu476a7c269c40
diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go
index 62a8969423..0edf501a8e 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()