Browse Source

1 Distinguish between folders and common files, folders are listed first

2 Add some custom headers that need to be exposed
pull/1719/head
henry 4 years ago
parent
commit
14ddd15508
  1. 12
      weed/filer/filer_search.go
  2. 10
      weed/server/filer_server_handlers_read.go

12
weed/filer/filer_search.go

@ -38,7 +38,17 @@ func (f *Filer) ListDirectoryEntries(ctx context.Context, p util.FullPath, start
} }
} }
return entries, err
//Distinguish between folders and common files, folders are listed first
var folderEntries, commonEntries []*Entry
for i, _ := range entries {
if entries[i].IsDirectory() {
folderEntries = append(folderEntries, entries[i])
} else {
commonEntries = append(commonEntries, entries[i])
}
}
folderEntries = append(folderEntries, commonEntries...)
return folderEntries, err
} }
func (f *Filer) doListPatternMatchedEntries(ctx context.Context, p util.FullPath, startFileName string, inclusive bool, limit int, prefix, restNamePattern string) (matchedEntries []*Entry, missedCount int, lastFileName string, err error) { func (f *Filer) doListPatternMatchedEntries(ctx context.Context, p util.FullPath, startFileName string, inclusive bool, limit int, prefix, restNamePattern string) (matchedEntries []*Entry, missedCount int, lastFileName string, err error) {

10
weed/server/filer_server_handlers_read.go

@ -100,6 +100,16 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
w.Header().Set(k, string(v)) w.Header().Set(k, string(v))
} }
//Add some custom headers that need to be exposed
seaweedHeaders := []string{}
for i, _ := range w.Header() {
if strings.Contains(i, "Seaweed") {
seaweedHeaders = append(seaweedHeaders, i)
}
}
seaweedHeaders = append(seaweedHeaders, "Content-Disposition")
w.Header().Set("Access-Control-Expose-Headers", strings.Join(seaweedHeaders, ","))
//set tag count //set tag count
if r.Method == "GET" { if r.Method == "GET" {
tagCount := 0 tagCount := 0

Loading…
Cancel
Save