package main import ( "fmt" "log" "os" "path/filepath" "runtime" "mcquay.me/arrange" ) // verify rehashes the content store. It only reads. func verify(dir string) error { if _, err := os.Stat(filepath.Join(dir, "content")); err != nil { return fmt.Errorf("couldn't find 'content' dir in %q: %v", dir, err) } workers := runtime.NumCPU() if *cores != 0 { workers = *cores } counts := map[string]int{} problems, checked := arrange.Verify(dir, workers) for p := range problems { counts[p.Kind]++ log.Printf("%v", p) } log.Printf("checked: %d, corrupt: %d, orphan: %d, stale: %d, errors: %d", checked(), counts["corrupt"], counts["orphan"], counts["stale"], counts["error"]) if counts["corrupt"]+counts["error"] > 0 { return fmt.Errorf("store has problems") } return nil }