From 27f67edb1a365e10e7b65423e4dd5ee164c0b399 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 17 Jan 2016 13:56:00 +0000 Subject: [PATCH] Fix formatting problem in sha1sum --- fs/hash.go | 6 ++++++ fs/operations.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/hash.go b/fs/hash.go index faf50176d..4fda65acd 100644 --- a/fs/hash.go +++ b/fs/hash.go @@ -32,6 +32,12 @@ const ( // HashStream and MultiHasher. var SupportedHashes = NewHashSet(HashMD5, HashSHA1) +// HashWidth returns the width in characters for any HashType +var HashWidth = map[HashType]int{ + HashMD5: 32, + HashSHA1: 40, +} + // HashStream will calculate hashes of all supported hash types. func HashStream(r io.Reader) (map[HashType]string, error) { return HashStreamTypes(r, SupportedHashes) diff --git a/fs/operations.go b/fs/operations.go index ba8464022..43ae2ef35 100644 --- a/fs/operations.go +++ b/fs/operations.go @@ -738,7 +738,7 @@ func hashLister(ht HashType, f Fs, w io.Writer) error { Debug(o, "Failed to read %v: %v", ht, err) sum = "ERROR" } - syncFprintf(w, "%32s %s\n", sum, o.Remote()) + syncFprintf(w, "%*s %s\n", HashWidth[ht], sum, o.Remote()) }) }