Scan for files with ALLCAPS extensions (#650)

This commit is contained in:
bnkai
2020-07-11 10:22:36 +03:00
committed by GitHub
parent 56210cf456
commit ec2bcc7a74
2 changed files with 8 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ package manager
import (
"path/filepath"
"strconv"
"strings"
"sync"
"time"
@@ -17,22 +18,17 @@ var extensionsToScan = []string{"zip", "m4v", "mp4", "mov", "wmv", "avi", "mpg",
var extensionsGallery = []string{"zip"}
func constructGlob() string { // create a sequence for glob doublestar from our extensions
extLen := len(extensionsToScan)
glb := "{"
for i := 0; i < extLen-1; i++ { // append extensions and commas
glb += extensionsToScan[i] + ","
var extList []string
for _, ext := range extensionsToScan {
extList = append(extList, strings.ToLower(ext))
extList = append(extList, strings.ToUpper(ext))
}
if extLen >= 1 { // append last extension without comma
glb += extensionsToScan[extLen-1]
}
glb += "}"
return glb
return "{" + strings.Join(extList, ",") + "}"
}
func isGallery(pathname string) bool {
for _, ext := range extensionsGallery {
if filepath.Ext(pathname) == "."+ext {
if strings.ToLower(filepath.Ext(pathname)) == "."+strings.ToLower(ext) {
return true
}
}