fichier: 1fichier support - fixes #2908

This was started by Fionera, finished off by Laura with fixes and more
docs from Nick.

Co-authored-by: Fionera <fionera@fionera.de>
Co-authored-by: Nick Craig-Wood <nick@craig-wood.com>
This commit is contained in:
Laura
2019-06-30 18:35:01 +01:00
committed by Nick Craig-Wood
co-authored by Fionera Nick Craig-Wood
parent 2d0e9885bd
commit dde4dd0198
19 changed files with 1314 additions and 1 deletions
+12 -1
View File
@@ -9,6 +9,7 @@ import (
"io"
"strings"
"github.com/jzelinskie/whirlpool"
"github.com/ncw/rclone/backend/dropbox/dbhash"
"github.com/ncw/rclone/backend/onedrive/quickxorhash"
"github.com/pkg/errors"
@@ -36,13 +37,16 @@ const (
// https://docs.microsoft.com/en-us/onedrive/developer/code-snippets/quickxorhash
QuickXorHash
// Whirlpool indicates Whirlpool support
Whirlpool
// None indicates no hashes are supported
None Type = 0
)
// Supported returns a set of all the supported hashes by
// HashStream and MultiHasher.
var Supported = NewHashSet(MD5, SHA1, Dropbox, QuickXorHash)
var Supported = NewHashSet(MD5, SHA1, Dropbox, QuickXorHash, Whirlpool)
// Width returns the width in characters for any HashType
var Width = map[Type]int{
@@ -50,6 +54,7 @@ var Width = map[Type]int{
SHA1: 40,
Dropbox: 64,
QuickXorHash: 40,
Whirlpool: 128,
}
// Stream will calculate hashes of all supported hash types.
@@ -89,6 +94,8 @@ func (h Type) String() string {
return "DropboxHash"
case QuickXorHash:
return "QuickXorHash"
case Whirlpool:
return "Whirlpool"
default:
err := fmt.Sprintf("internal error: unknown hash type: 0x%x", int(h))
panic(err)
@@ -108,6 +115,8 @@ func (h *Type) Set(s string) error {
*h = Dropbox
case "QuickXorHash":
*h = QuickXorHash
case "Whirlpool":
*h = Whirlpool
default:
return errors.Errorf("Unknown hash type %q", s)
}
@@ -138,6 +147,8 @@ func fromTypes(set Set) (map[Type]hash.Hash, error) {
hashers[t] = dbhash.New()
case QuickXorHash:
hashers[t] = quickxorhash.New()
case Whirlpool:
hashers[t] = whirlpool.New()
default:
err := fmt.Sprintf("internal error: Unsupported hash type %v", t)
panic(err)
+2
View File
@@ -73,6 +73,7 @@ var hashTestSet = []hashTest{
hash.SHA1: "3ab6543c08a75f292a5ecedac87ec41642d12166",
hash.Dropbox: "214d2fcf3566e94c99ad2f59bd993daca46d8521a0c447adf4b324f53fddc0c7",
hash.QuickXorHash: "0110c000085000031c0001095ec00218d0000700",
hash.Whirlpool: "eddf52133d4566d763f716e853d6e4efbabd29e2c2e63f56747b1596172851d34c2df9944beb6640dbdbe3d9b4eb61180720a79e3d15baff31c91e43d63869a4",
},
},
// Empty data set
@@ -83,6 +84,7 @@ var hashTestSet = []hashTest{
hash.SHA1: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
hash.Dropbox: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
hash.QuickXorHash: "0000000000000000000000000000000000000000",
hash.Whirlpool: "19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3",
},
},
}