dm/cs
1
0
forked from sm/cs

allow for spaces in filenames

This commit is contained in:
Stephen McQuay 2016-12-01 21:53:41 -08:00
parent d01b28973b
commit 7f3fe3ce4e
No known key found for this signature in database
GPG Key ID: 1ABF428F71BAFC3D

View File

@ -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).