From 14ddd155082a455542a992220d6c61e658420c6b Mon Sep 17 00:00:00 2001 From: henry Date: Thu, 31 Dec 2020 00:03:22 +0800 Subject: [PATCH 1/8] 1 Distinguish between folders and common files, folders are listed first 2 Add some custom headers that need to be exposed --- weed/filer/filer_search.go | 12 +++++++++++- weed/server/filer_server_handlers_read.go | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/weed/filer/filer_search.go b/weed/filer/filer_search.go index b26959cb0..2fe83b49d 100644 --- a/weed/filer/filer_search.go +++ b/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) { diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go index 4d61193ec..28027a009 100644 --- a/weed/server/filer_server_handlers_read.go +++ b/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)) } + //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 if r.Method == "GET" { tagCount := 0 From e5a3ad372fff51f882a03498d523990b5bca2a4c Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 5 Jan 2021 11:17:04 +0800 Subject: [PATCH 2/8] gitignore --- .gitignore | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index 671b01051..7a45c2ea0 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,21 @@ other/java/hdfs/dependency-reduced-pom.xml # binary file weed/weed + + + +weed-ui/node_modules/ +weed-ui/dist/ +weed-ui/npm-debug.log* +weed-ui/yarn-debug.log* +weed-ui/yarn-error.log* +weed-ui//test/e2e/reports/ +weed-ui/selenium-debug.log + +# Editor directories and files + +weed-ui/.vscode +*.suo +*.ntvs* +*.njsproj +*.sln \ No newline at end of file From 942a30f04c74d7a73dce4169d558358ee7fd6689 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 5 Jan 2021 12:24:32 +0800 Subject: [PATCH 3/8] remove sort --- weed/filer/filer_search.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/weed/filer/filer_search.go b/weed/filer/filer_search.go index 7489d8e34..34358d849 100644 --- a/weed/filer/filer_search.go +++ b/weed/filer/filer_search.go @@ -42,17 +42,7 @@ func (f *Filer) ListDirectoryEntries(ctx context.Context, p util.FullPath, start } } - //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 + return entries, 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) { From e92ce1d51756cd3b1a311bf241f89df000c510a6 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 5 Jan 2021 12:26:51 +0800 Subject: [PATCH 4/8] remove sort --- .gitignore | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.gitignore b/.gitignore index 7a45c2ea0..ca451260a 100644 --- a/.gitignore +++ b/.gitignore @@ -85,19 +85,3 @@ other/java/hdfs/dependency-reduced-pom.xml weed/weed - -weed-ui/node_modules/ -weed-ui/dist/ -weed-ui/npm-debug.log* -weed-ui/yarn-debug.log* -weed-ui/yarn-error.log* -weed-ui//test/e2e/reports/ -weed-ui/selenium-debug.log - -# Editor directories and files - -weed-ui/.vscode -*.suo -*.ntvs* -*.njsproj -*.sln \ No newline at end of file From 247d5eed937f624228e629fa5e89406616e26dd5 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 5 Jan 2021 12:27:26 +0800 Subject: [PATCH 5/8] remove sort --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index ca451260a..473918513 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,3 @@ other/java/hdfs/dependency-reduced-pom.xml # binary file weed/weed - From e4ee25e6f0cd2b10b2f7745f5847845185bf2858 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 5 Jan 2021 12:29:46 +0800 Subject: [PATCH 6/8] remove sort --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 473918513..671b01051 100644 --- a/.gitignore +++ b/.gitignore @@ -83,4 +83,3 @@ other/java/hdfs/dependency-reduced-pom.xml # binary file weed/weed - From 1309dfe612ae818134d2241c38fc3858516ea729 Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 5 Jan 2021 12:58:46 +0800 Subject: [PATCH 7/8] Seaweed custom header are not visible to Vue or javascript --- weed/server/filer_server_handlers_read.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go index 28027a009..46a7ca9d9 100644 --- a/weed/server/filer_server_handlers_read.go +++ b/weed/server/filer_server_handlers_read.go @@ -102,9 +102,9 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, //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) + for header, _ := range w.Header() { + if strings.HasPrefix(header, "Seaweed-") { + seaweedHeaders = append(seaweedHeaders, header) } } seaweedHeaders = append(seaweedHeaders, "Content-Disposition") From b42c5b71c1ec97bd096785ee1428fe257f10c88b Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 5 Jan 2021 13:01:29 +0800 Subject: [PATCH 8/8] Seaweed custom header are not visible to Vue or javascript --- weed/server/filer_server_handlers_read.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go index 46a7ca9d9..5cfbfe86c 100644 --- a/weed/server/filer_server_handlers_read.go +++ b/weed/server/filer_server_handlers_read.go @@ -100,7 +100,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, w.Header().Set(k, string(v)) } - //Add some custom headers that need to be exposed + //Seaweed custom header are not visible to Vue or javascript seaweedHeaders := []string{} for header, _ := range w.Header() { if strings.HasPrefix(header, "Seaweed-") {