summaryrefslogtreecommitdiff
path: root/go/src/cow-dedupe/dedupe.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/src/cow-dedupe/dedupe.go')
-rw-r--r--go/src/cow-dedupe/dedupe.go28
1 files changed, 17 insertions, 11 deletions
diff --git a/go/src/cow-dedupe/dedupe.go b/go/src/cow-dedupe/dedupe.go
index ea60604..a47e31f 100644
--- a/go/src/cow-dedupe/dedupe.go
+++ b/go/src/cow-dedupe/dedupe.go
@@ -26,6 +26,10 @@ func errhandle(err error) {
}
}
+func myStatusLine() statusline.StatusLine {
+ return statusline.StopWatch(statusline.RateLimit(statusline.New(os.Stderr), time.Second/2), time.Second)
+}
+
func getFiemaps(paths []string) map[string][]string {
var err error
for i := range paths {
@@ -35,7 +39,7 @@ func getFiemaps(paths []string) map[string][]string {
ret := map[string][]string{}
- sl := statusline.NewAsyncStatusLine(os.Stderr, time.Second/2)
+ sl := myStatusLine()
cnt := 0
sl.Put("Mapping extents...")
@@ -71,15 +75,15 @@ func getFiemaps(paths []string) map[string][]string {
}
errhandle(cmd.Wait())
- sl.End()
- fmt.Fprintf(os.Stderr, "Mapping extents... done; mapped %d files\n", cnt)
+ sl.Put(fmt.Sprintf("Mapping extents... done; mapped %d files", cnt))
+ sl.End(true)
return ret
}
func getChecksums(paths []string) map[string][]string {
ret := map[string][]string{}
- sl := statusline.NewAsyncStatusLine(os.Stderr, time.Second/2)
+ sl := myStatusLine()
cnt := 0
sl.Put(fmt.Sprintf("Generating checksums for files... %d/%d", cnt, len(paths)))
@@ -121,8 +125,8 @@ func getChecksums(paths []string) map[string][]string {
errhandle(cmd.Wait())
}
- sl.End()
- fmt.Fprintf(os.Stderr, "Generating checksums for files... done; summed %d files\n", cnt)
+ sl.Put(fmt.Sprintf("Generating checksums for files... done; summed %d files", cnt))
+ sl.End(true)
return ret
}
@@ -133,7 +137,8 @@ func main() {
fiemap2filenames := getFiemaps(os.Args[1:])
- fmt.Fprintf(os.Stderr, "Building list of spanning files...")
+ sl := statusline.StopWatch(statusline.New(os.Stderr), time.Second)
+ sl.Put( "Building list of spanning files...")
filename2fiemap := map[string]string{}
for fiemap, filenames := range fiemap2filenames {
@@ -152,7 +157,8 @@ func main() {
i++
}
- fmt.Fprintf(os.Stderr, " done (%d files)\n", len(spanningFiles))
+ sl.Put(fmt.Sprintf("Building list of spanning files... done; %d files", len(spanningFiles)))
+ sl.End(true)
checksum2filenames := getChecksums(spanningFiles)
@@ -168,7 +174,7 @@ func main() {
}
}
- sl := statusline.NewAsyncStatusLine(os.Stderr, time.Second/2)
+ sl = myStatusLine()
cnt := 0
sl.Put(fmt.Sprintf("Deduplicating sets of files... %d/%d", cnt, len(checksum2fiemaps)))
for checksum, fiemaps := range checksum2fiemaps {
@@ -211,6 +217,6 @@ func main() {
cnt++
sl.Put(fmt.Sprintf("Deduplicating sets of files... %d/%d", cnt, len(checksum2fiemaps)))
}
- sl.End()
- fmt.Fprintf(os.Stderr, "Deduplicating sets of files... done; deduplicated %d sets", cnt)
+ sl.Put(fmt.Sprintf("Deduplicating sets of files... done; deduplicated %d sets", cnt))
+ sl.End(true)
}