summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@beefcake.parabola.nu>2018-05-20 12:06:01 -0400
committerLuke Shumaker <lukeshu@beefcake.parabola.nu>2018-05-20 12:06:01 -0400
commitebf320ee2b1553d0894aacc5b12c646050ba9762 (patch)
tree2b467af0c20fed2f6af931071645597e6404e27d
parentdfd75aa7fc93ead05bb5ff3b2c3b4e6d2fc89ad9 (diff)
better status
-rw-r--r--go/src/cow-dedupe/dedupe.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/go/src/cow-dedupe/dedupe.go b/go/src/cow-dedupe/dedupe.go
index 84140f5..af2063a 100644
--- a/go/src/cow-dedupe/dedupe.go
+++ b/go/src/cow-dedupe/dedupe.go
@@ -160,15 +160,16 @@ func dedupe(srcFile string, dupFiles []string) error {
type fancyStatus struct {
sizeN, sizeD, sizeC int
sumT, sumN, sumD, sumC int
- summed, deduped int
+ summed, deduped, errs int
verb string
}
func (s fancyStatus) String() string {
- return fmt.Sprintf("size-set[%d/%d]->%d :: sha256-set[%d+%d/%d]->%d :: (summed=%d deduped=%d) :: %s",
+ return fmt.Sprintf("size-set[%d/%d]->%d :: sha256-set[%d+%d/%d]->%d :: (sum=%d dedup=%d err=%d) :: %s",
s.sizeN, s.sizeD, s.sizeC,
s.sumT, s.sumN, s.sumD, s.sumC,
- s.summed, s.deduped, s.verb)
+ s.summed, s.deduped, s.errs,
+ s.verb)
}
func main() {
@@ -253,10 +254,18 @@ func main() {
dupFiles = append(dupFiles, fiemap2filenames[fiemap]...)
}
// And actually dedupe those
- status.verb = fmt.Sprintf("dedupe %q (and %d more)", filepath.Base(srcFile), len(dupFiles))
+ name := filepath.Base(srcFile)
+ if len(name) > 25 {
+ name = name[:25]
+ }
+ status.verb = fmt.Sprintf("dedupe %q (and %d more)", name, len(dupFiles))
sl.Put(status.String())
- dedupe(srcFile, dupFiles) // XXX ignore error?
- status.deduped++
+ err := dedupe(srcFile, dupFiles)
+ if err != nil {
+ status.errs++
+ } else {
+ status.deduped++
+ }
status.sumN++
}
status.sumT += len(checksum2filenames)