diff options
author | Luke Shumaker <lukeshu@beefcake.parabola.nu> | 2018-05-18 22:57:46 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@beefcake.parabola.nu> | 2018-05-18 22:57:46 -0400 |
commit | 9018cb140b386582a1c0f19e7dbd8026960b3803 (patch) | |
tree | dd448603ec690fc83768e127afc61cf1121f80ca | |
parent | 078ec064d48a80b28ae12ccfdc975cd497d4e374 (diff) |
dedupe: show status on slow commands
-rw-r--r-- | dedupe.go | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -65,18 +65,18 @@ func getFiemaps(paths []string) map[string][]string { ret := map[string][]string{} fmt.Fprintf(os.Stderr, "Getting fiemaps for %d files...\n", len(paths)) + cnt := 0 for len(paths) > 0 { _paths := paths arg_len := 0 for i := range _paths { - arg_len += len(_paths[i])+1 + arg_len += len(_paths[i]) + 1 if arg_len > arg_max/2 { _paths = _paths[:i-1] break } } paths = paths[len(_paths):] - fmt.Fprintf(os.Stderr, " -> %d\n", len(_paths)) cmd := exec.Command("./cow-extent-map", append([]string{"-m", "--"}, _paths...)...) stdout, err := cmd.StdoutPipe() @@ -102,11 +102,13 @@ func getFiemaps(paths []string) map[string][]string { errhandle(err) ret[fiemap] = append(ret[fiemap], filename) + cnt++ + fmt.Fprintf(os.Stderr, "\r%d ", cnt) } errhandle(cmd.Wait()) } - fmt.Fprintf(os.Stderr, "...done\n") + fmt.Fprintf(os.Stderr, "\r...done \n") return ret } @@ -114,18 +116,18 @@ func getChecksums(paths []string) map[string][]string { ret := map[string][]string{} fmt.Fprintf(os.Stderr, "Generating checksums for %d files...\n", len(paths)) + cnt := 0 for len(paths) > 0 { _paths := paths arg_len := 0 for i := range _paths { - arg_len += len(_paths[i])+1 + arg_len += len(_paths[i]) + 1 if arg_len > arg_max/2 { _paths = _paths[:i-1] break } } paths = paths[len(_paths):] - fmt.Fprintf(os.Stderr, " -> %d\n", len(_paths)) cmd := exec.Command("sha256sum", append([]string{"--"}, _paths...)...) stdout, err := cmd.StdoutPipe() @@ -147,11 +149,13 @@ func getChecksums(paths []string) map[string][]string { filename := strings.TrimPrefix(parts[1], " ") ret[checksum] = append(ret[checksum], filename) + cnt++ + fmt.Fprintf(os.Stderr, "\r%d ", cnt) } errhandle(cmd.Wait()) } - fmt.Fprintf(os.Stderr, "...done\n") + fmt.Fprintf(os.Stderr, "\r...done \n") return ret } |