diff options
-rw-r--r-- | go/src/cow-dedupe/dedupe.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/go/src/cow-dedupe/dedupe.go b/go/src/cow-dedupe/dedupe.go index a47e31f..b70aeb2 100644 --- a/go/src/cow-dedupe/dedupe.go +++ b/go/src/cow-dedupe/dedupe.go @@ -87,19 +87,20 @@ func getChecksums(paths []string) map[string][]string { cnt := 0 sl.Put(fmt.Sprintf("Generating checksums for files... %d/%d", cnt, len(paths))) - for len(paths) > 0 { - _paths := paths + pathsTodo := paths + for len(pathsTodo) > 0 { + pathsDoing := pathsTodo arg_len := 0 - for i := range _paths { - arg_len += len(_paths[i]) + 1 + for i := range pathsDoing { + arg_len += len(pathsDoing[i]) + 1 if arg_len > arg_max/2 { - _paths = _paths[:i-1] + pathsDoing = pathsDoing[:i-1] break } } - paths = paths[len(_paths):] + pathsTodo = pathsTodo[len(pathsDoing):] - cmd := exec.Command("sha256sum", append([]string{"--"}, _paths...)...) + cmd := exec.Command("sha256sum", append([]string{"--"}, pathsDoing...)...) stdout, err := cmd.StdoutPipe() errhandle(err) cmd.Stderr = os.Stderr |