summaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@beefcake.parabola.nu>2018-05-20 00:46:00 -0400
committerLuke Shumaker <lukeshu@beefcake.parabola.nu>2018-05-20 00:46:00 -0400
commita34d01041d55784b7678e64a8e6ae0760a7f881e (patch)
tree52fa91c7144a0d1310401bb171c73a80e9b4a156 /go
parent2c0d4c741d6da293446ce5d0f19a94e6ffe5a37a (diff)
cow-dedupe: better statuses
Diffstat (limited to 'go')
-rw-r--r--go/src/cow-dedupe/dedupe.go16
-rw-r--r--go/src/lib/statusline/prefix.go21
2 files changed, 29 insertions, 8 deletions
diff --git a/go/src/cow-dedupe/dedupe.go b/go/src/cow-dedupe/dedupe.go
index 0268ed3..457e377 100644
--- a/go/src/cow-dedupe/dedupe.go
+++ b/go/src/cow-dedupe/dedupe.go
@@ -80,10 +80,9 @@ func getFiemaps(paths []string) map[string][]string {
return ret
}
-func getChecksums(cmd []string, paths []string) map[string][]string {
+func getChecksums(sl statusline.StatusLine, cmd []string, paths []string) map[string][]string {
ret := map[string][]string{}
- sl := myStatusLine()
cnt := 0
sl.Put(fmt.Sprintf("Generating checksums (%v) for files... %d/%d", cmd, cnt, len(paths)))
@@ -188,14 +187,14 @@ func main() {
sl.Put(fmt.Sprintf("Building list of spanning files... done; %d files", len(spanningFiles)))
sl.End(true)
- size2filenames := getChecksums([]string{"stat", "--printf=%s %n\\n", "--"}, spanningFiles)
- fmt.Fprintf(" -> %d sets", len(size2filenames))
+ size2filenames := getChecksums(myStatusLine(), []string{"stat", "--printf=%s %n\\n", "--"}, spanningFiles)
+ fmt.Fprintf(os.Stderr, " -> %d sets", len(size2filenames))
pruneSingles(size2filenames)
- fmt.Fprintf(" -> %d non-trivial sets\n", len(size2filenames))
+ fmt.Fprintf(os.Stderr, " -> %d non-trivial sets\n", len(size2filenames))
sl = myStatusLine()
sizeCnt := 0
- for size, filenames := range size2filenames {
+ for _, filenames := range size2filenames {
// The list of specific files in size2filenames isn't
// significant; they'e just proxies for fiemaps.
sizeStatus := fmt.Sprintf("Working on size-set %d/%d of %d fiemaps",
@@ -203,11 +202,12 @@ func main() {
sl.Put(sizeStatus)
// Now do strict hashing, instead of the incredibly
// sloppy (but fast) size-bucketing.
- checksum2filenames := getChecksums([]string{"sha256sum", "--"}, filenames)
+ checksum2filenames := getChecksums(statusline.Prefix(myStatusLine(), sizeStatus+" :: "), []string{"sha256sum", "--"}, filenames)
+ sl.Put(sizeStatus)
pruneSingles(checksum2filenames)
// And loop over the smaller, precise buckets
sumCnt := 0
- for checksum, filenames := range checksum2fiemaps {
+ for _, filenames := range checksum2filenames {
sl.Put(fmt.Sprintf("%s :: sha256-set %d/%d of %d fiemaps", sizeStatus, sumCnt, len(checksum2filenames), len(filenames)))
var fiemaps []string
for _, filename := range filenames {
diff --git a/go/src/lib/statusline/prefix.go b/go/src/lib/statusline/prefix.go
new file mode 100644
index 0000000..9373410
--- /dev/null
+++ b/go/src/lib/statusline/prefix.go
@@ -0,0 +1,21 @@
+package statusline
+
+type prefix struct {
+ inner StatusLine
+ prefix string
+}
+
+func Prefix(sl StatusLine, pfix string) StatusLine {
+ return &prefix{
+ inner: sl,
+ prefix: pfix,
+ }
+}
+
+func (sl *prefix) Put(line string) {
+ sl.inner.Put(sl.prefix+line)
+}
+
+func (sl *prefix) End(keep bool) {
+ sl.inner.End(keep)
+}