Remove unneeded(?) prepareDirectory() function
This commit is contained in:
parent
ce99374a9f
commit
bfb04cab66
30
cmd/files.go
30
cmd/files.go
|
@ -171,8 +171,8 @@ func appendPaths(path string, files *files, filters *filters, stats *scanStats,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFile(paths []string, filters *filters, sortOrder string, regexes *regexes, index *fileCache, formats *types.Types) (string, error) {
|
func newFile(paths []string, filters *filters, sortOrder string, regexes *regexes, cache *fileCache, formats *types.Types) (string, error) {
|
||||||
path, err := pickFile(paths, filters, sortOrder, index, formats)
|
path, err := pickFile(paths, filters, sortOrder, cache, formats)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
@ -505,24 +505,6 @@ func fileList(paths []string, filters *filters, sort string, cache *fileCache, f
|
||||||
return fileList, false
|
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 []string{directory[0]}
|
|
||||||
} else {
|
|
||||||
return directory
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareDirectories(files *files, sort string) []string {
|
func prepareDirectories(files *files, sort string) []string {
|
||||||
directories := []string{}
|
directories := []string{}
|
||||||
|
|
||||||
|
@ -534,15 +516,9 @@ func prepareDirectories(files *files, sort string) []string {
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
if sort == "asc" || sort == "desc" {
|
|
||||||
for i := 0; i < len(keys); i++ {
|
|
||||||
directories = append(directories, prepareDirectory(files.list[keys[i]])...)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for i := 0; i < len(keys); i++ {
|
for i := 0; i < len(keys); i++ {
|
||||||
directories = append(directories, files.list[keys[i]]...)
|
directories = append(directories, files.list[keys[i]]...)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return directories
|
return directories
|
||||||
}
|
}
|
||||||
|
@ -618,7 +594,7 @@ func normalizePath(path string) (string, error) {
|
||||||
return absolutePath, nil
|
return absolutePath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizePaths(args []string, formats *types.Types) ([]string, error) {
|
func validatePaths(args []string, formats *types.Types) ([]string, error) {
|
||||||
var paths []string
|
var paths []string
|
||||||
|
|
||||||
var pathList strings.Builder
|
var pathList strings.Builder
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ReleaseVersion string = "0.79.0"
|
ReleaseVersion string = "0.80.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -332,7 +332,7 @@ func ServePage(args []string) error {
|
||||||
formats.Add(images.New())
|
formats.Add(images.New())
|
||||||
}
|
}
|
||||||
|
|
||||||
paths, err := normalizePaths(args, formats)
|
paths, err := validatePaths(args, formats)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
BIN
default.pgo
BIN
default.pgo
Binary file not shown.
Loading…
Reference in New Issue