Readded checks in prepareDirectory to avoid redirect issue with sort=asc

This commit is contained in:
Seednode 2023-02-18 13:38:18 -06:00
parent ce4c1e8171
commit e2356c180f
3 changed files with 27 additions and 3 deletions

View File

@ -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,9 +538,15 @@ func prepareDirectories(files *Files, sort string) []string {
directories := make([]string, l)
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()

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"
)
var Version = "0.38.0"
var Version = "0.38.1"
func init() {
rootCmd.AddCommand(versionCmd)

BIN
stats.file Normal file

Binary file not shown.