diff options
author | Christian Pointner <equinox@helsinki.at> | 2017-01-27 23:13:56 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2017-01-27 23:13:56 (GMT) |
commit | b79d589aad52792560eb8d42946cb96872973da2 (patch) | |
tree | c33d118fc4a9aed0c978803a3e60112c2c20da50 /src/file-hasher/main.go | |
parent | f1511737680385da81972bb76ec1ba1f2b6c46a1 (diff) |
make hash algorithm configurable
Diffstat (limited to 'src/file-hasher/main.go')
-rw-r--r-- | src/file-hasher/main.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/file-hasher/main.go b/src/file-hasher/main.go index f360705..c7718ee 100644 --- a/src/file-hasher/main.go +++ b/src/file-hasher/main.go @@ -31,9 +31,12 @@ import ( ) type Request struct { - NumThreads uint `json:"threads"` - Directories []string `json:"dir"` - M3UPlaylists []string `json:"m3u"` + NumThreads uint `json:"threads"` + HashAlgo string `json:"algo"` + Sources struct { + Directories []string `json:"dir"` + M3UPlaylists []string `json:"m3u"` + } `json:"src"` } func main() { @@ -53,11 +56,14 @@ func main() { C <- syscall.SIGTERM }() stdlog.Println("***************************************************************") - h := NewHasher(req.NumThreads, stdlog) + h := NewHasher(req.HashAlgo, req.NumThreads, stdlog) + if h == nil { + os.Exit(1) + } stdlog.Println("") stdlog.Println("******************************") - for _, root := range req.Directories { + for _, root := range req.Sources.Directories { src := NewDir(root, stdlog) stdlog.Printf("*** hashing all the files in '%s'", root) stdlog.Println("") @@ -68,7 +74,7 @@ func main() { stdlog.Println("") stdlog.Println("******************************") } - for _, list := range req.M3UPlaylists { + for _, list := range req.Sources.M3UPlaylists { src := NewM3u(list, stdlog) stdlog.Printf("*** hashing all the files from '%s'", list) stdlog.Println("") |