From a05725aea6b6c4e99a5b6d9541b94fd7bbd15ab9 Mon Sep 17 00:00:00 2001 From: zemul Date: Wed, 12 Oct 2022 22:14:49 +0800 Subject: [PATCH] filer: get directory metadata (#3833) --- weed/server/filer_server_handlers_read.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go index 8c3d4bcd8..645a3fb44 100644 --- a/weed/server/filer_server_handlers_read.go +++ b/weed/server/filer_server_handlers_read.go @@ -107,9 +107,15 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request) return } + query := r.URL.Query() + if entry.IsDirectory() { if fs.option.DisableDirListing { - w.WriteHeader(http.StatusMethodNotAllowed) + w.WriteHeader(http.StatusForbidden) + return + } + if query.Get("metadata") == "true" { + writeJsonQuiet(w, r, http.StatusOK, entry) return } if entry.Attr.Mime == "" { @@ -125,7 +131,6 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request) return } - query := r.URL.Query() if query.Get("metadata") == "true" { if query.Get("resolveManifest") == "true" { if entry.Chunks, _, err = filer.ResolveChunkManifest(