From 7f3fe3ce4e9898f7203d23230b0e8ac530438566 Mon Sep 17 00:00:00 2001 From: "Stephen McQuay (smcquay)" Date: Thu, 1 Dec 2016 21:53:41 -0800 Subject: [PATCH] allow for spaces in filenames --- check.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/check.go b/check.go index 3318f2b..7333af2 100644 --- a/check.go +++ b/check.go @@ -83,10 +83,10 @@ func toInput(args []string) chan input { // needed to perform a checksum. func parseCS(line string) checksum { elems := strings.Fields(line) - if len(elems) != 2 { - return checksum{err: fmt.Errorf("unexpected content: %d != 2", len(elems))} + if len(elems) < 1 { + return checksum{err: fmt.Errorf("couldn't find checksum in %q", line)} } - cs, f := elems[0], elems[1] + cs := elems[0] var hsh hash.Hash switch len(cs) { case 32: @@ -100,7 +100,8 @@ func parseCS(line string) checksum { default: return checksum{err: fmt.Errorf("unknown format: %q", line)} } - return checksum{filename: f, hash: hsh, checksum: cs} + + return checksum{filename: strings.TrimSpace(line[len(cs):]), hash: hsh, checksum: cs} } // verify does grunt work of verifying a stream of jobs (filenames).