Browse Source

fix get file metadata bug (#5394)

* Removed problematic if statement

This if statement was causing the value of option.AllowedOrigins to be always equal to "*". Now the values in the config file will be used when present. This allows for people who don't need this feature to not update their security.toml files.

* Update filer_server_handers_read.go

* Updated filer responses to invalid requests
pull/5395/head
jerebear12 9 months ago
committed by GitHub
parent
commit
7091269e65
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      weed/server/filer_server_handlers_read.go
  2. 5
      weed/server/filer_server_handlers_read_dir.go

10
weed/server/filer_server_handlers_read.go

@ -3,6 +3,7 @@ package weed_server
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"math" "math"
@ -117,10 +118,13 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
w.WriteHeader(http.StatusForbidden) w.WriteHeader(http.StatusForbidden)
return return
} }
if query.Get("metadata") == "true" && fs.option.ExposeDirectoryData != false {
writeJsonQuiet(w, r, http.StatusOK, entry)
if query.Get("metadata") == "true" {
// Don't return directory meta if config value is set to true
if fs.option.ExposeDirectoryData == false {
writeJsonError(w, r, http.StatusForbidden, errors.New("directory listing is disabled"))
return return
} }
}
if entry.Attr.Mime == "" || (entry.Attr.Mime == s3_constants.FolderMimeType && r.Header.Get(s3_constants.AmzIdentityId) == "") { if entry.Attr.Mime == "" || (entry.Attr.Mime == s3_constants.FolderMimeType && r.Header.Get(s3_constants.AmzIdentityId) == "") {
// return index of directory for non s3 gateway // return index of directory for non s3 gateway
fs.listDirectoryHandler(w, r) fs.listDirectoryHandler(w, r)
@ -135,7 +139,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
return return
} }
if query.Get("metadata") == "true" && fs.option.ExposeDirectoryData != false {
if query.Get("metadata") == "true" {
if query.Get("resolveManifest") == "true" { if query.Get("resolveManifest") == "true" {
if entry.Chunks, _, err = filer.ResolveChunkManifest( if entry.Chunks, _, err = filer.ResolveChunkManifest(
fs.filer.MasterClient.GetLookupFileIdFunction(), fs.filer.MasterClient.GetLookupFileIdFunction(),

5
weed/server/filer_server_handlers_read_dir.go

@ -2,6 +2,7 @@ package weed_server
import ( import (
"context" "context"
"errors"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@ -12,14 +13,14 @@ import (
"github.com/seaweedfs/seaweedfs/weed/util" "github.com/seaweedfs/seaweedfs/weed/util"
) )
// listDirectoryHandler lists directories and folers under a directory
// listDirectoryHandler lists directories and folders under a directory
// files are sorted by name and paginated via "lastFileName" and "limit". // files are sorted by name and paginated via "lastFileName" and "limit".
// sub directories are listed on the first page, when "lastFileName" // sub directories are listed on the first page, when "lastFileName"
// is empty. // is empty.
func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Request) { func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Request) {
if fs.option.ExposeDirectoryData == false { if fs.option.ExposeDirectoryData == false {
http.NotFound(w, r)
writeJsonError(w, r, http.StatusForbidden, errors.New("ui is disabled"))
return return
} }

Loading…
Cancel
Save