From e2356c180ff87017b3ca00828546a93faf935409 Mon Sep 17 00:00:00 2001 From: Seednode Date: Sat, 18 Feb 2023 13:38:18 -0600 Subject: [PATCH] Readded checks in prepareDirectory to avoid redirect issue with sort=asc --- cmd/files.go | 28 ++++++++++++++++++++++++++-- cmd/version.go | 2 +- stats.file | Bin 0 -> 1648 bytes 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 stats.file diff --git a/cmd/files.go b/cmd/files.go index 8be3d80..86262f9 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -505,6 +505,24 @@ func fileList(paths []string, filters *Filters, sort string, index *Index) ([]st return fileList, false } +func cleanFilename(filename string) string { + return filename[:len(filename)-(len(filepath.Ext(filename))+3)] +} + +func prepareDirectory(directory []string) []string { + _, first := filepath.Split(directory[0]) + first = cleanFilename(first) + + _, last := filepath.Split(directory[len(directory)-1]) + last = cleanFilename(last) + + if first == last { + return append([]string{}, directory[0]) + } else { + return directory + } +} + func prepareDirectories(files *Files, sort string) []string { i, l := 0, 0 @@ -520,8 +538,14 @@ func prepareDirectories(files *Files, sort string) []string { directories := make([]string, l) - for i := 0; i < len(keys); i++ { - copy(directories, files.list[keys[i]]) + if sort == "asc" || sort == "desc" { + for i := 0; i < len(keys); i++ { + copy(directories, prepareDirectory(files.list[keys[i]])) + } + } else { + for i := 0; i < len(keys); i++ { + copy(directories, files.list[keys[i]]) + } } files.mutex.RUnlock() diff --git a/cmd/version.go b/cmd/version.go index f22ed8d..e21f671 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.38.0" +var Version = "0.38.1" func init() { rootCmd.AddCommand(versionCmd) diff --git a/stats.file b/stats.file new file mode 100644 index 0000000000000000000000000000000000000000..232038bde6b13153ba9844bdf4323d07ef5fc386 GIT binary patch literal 1648 zcmV-$29NnDwJ-f-luH#e0E$2;3_DPbQXn%kGo#7O%*>1_#3vx_0I|{@B6mH=B!T71 z8ntb#GO#$Y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