summaryrefslogtreecommitdiff
path: root/src/file-hasher
diff options
context:
space:
mode:
Diffstat (limited to 'src/file-hasher')
-rw-r--r--src/file-hasher/dir-hasher.go6
-rw-r--r--src/file-hasher/main.go10
2 files changed, 11 insertions, 5 deletions
diff --git a/src/file-hasher/dir-hasher.go b/src/file-hasher/dir-hasher.go
index aa204a0..7f5e45b 100644
--- a/src/file-hasher/dir-hasher.go
+++ b/src/file-hasher/dir-hasher.go
@@ -74,7 +74,11 @@ func handleEntry(C chan<- string, path string, info os.FileInfo, err error, stdl
case ".mp4":
fallthrough
case ".m4a":
- C <- path
+ if absPath, err := filepath.Abs(path); err != nil {
+ stdlog.Printf(" - skipping (%v): %s", err, info.Name())
+ } else {
+ C <- absPath
+ }
default:
stdlog.Printf(" - skipping (unknown extension): %s", info.Name())
}
diff --git a/src/file-hasher/main.go b/src/file-hasher/main.go
index c25f690..1bb0132 100644
--- a/src/file-hasher/main.go
+++ b/src/file-hasher/main.go
@@ -22,6 +22,7 @@
package main
import (
+ "encoding/json"
"log"
"os"
"os/signal"
@@ -68,13 +69,14 @@ func main() {
stdlog.Println("******************************")
}
stdlog.Println("")
- for hash, file := range allFiles {
- stdlog.Printf("%s: %s", hash, file)
- }
- stdlog.Println("")
stdlog.Println("***************************************************************")
stdlog.Printf("*** hashed %d files in %v", len(allFiles), time.Since(starttime))
stdlog.Println("***************************************************************")
+
+ enc := json.NewEncoder(os.Stdout)
+ if err := enc.Encode(allFiles); err != nil {
+ stdlog.Printf("Error encoding JSON: %v", err)
+ }
}()
<-C