summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/file-hasher/main.go7
-rw-r--r--src/file-hasher/walker.go24
2 files changed, 17 insertions, 14 deletions
diff --git a/src/file-hasher/main.go b/src/file-hasher/main.go
index c7718ee..7100496 100644
--- a/src/file-hasher/main.go
+++ b/src/file-hasher/main.go
@@ -26,6 +26,7 @@ import (
"log"
"os"
"os/signal"
+ "strings"
"syscall"
"time"
)
@@ -37,6 +38,7 @@ type Request struct {
Directories []string `json:"dir"`
M3UPlaylists []string `json:"m3u"`
} `json:"src"`
+ ValidExtensions []string `json:"valid-ext"`
}
func main() {
@@ -47,6 +49,11 @@ func main() {
stdlog.Fatalf("Error decoding request: %v", err)
}
+ validExtensions = req.ValidExtensions
+ for i, ext := range validExtensions {
+ validExtensions[i] = strings.ToLower(ext)
+ }
+
C := make(chan os.Signal, 1)
signal.Notify(C, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM)
diff --git a/src/file-hasher/walker.go b/src/file-hasher/walker.go
index cc543a2..602f974 100644
--- a/src/file-hasher/walker.go
+++ b/src/file-hasher/walker.go
@@ -26,23 +26,19 @@ import (
"strings"
)
+var validExtensions []string
+
func checkFileExt(path string) bool {
- switch strings.ToLower(filepath.Ext(path)) {
- case ".flac":
- return true
- case ".ogg":
- return true
- case ".wav":
- return true
- case ".mp3":
- return true
- case ".aac":
- return true
- case ".mp4":
- return true
- case ".m4a":
+ if len(validExtensions) == 0 {
return true
}
+
+ ext := strings.ToLower(filepath.Ext(path))
+ for _, e := range validExtensions {
+ if ext == "."+e {
+ return true
+ }
+ }
return false
}