mirror of
https://github.com/kopia/kopia.git
synced 2026-05-18 19:54:37 -04:00
added version number support
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
||||
all: lint vet build
|
||||
all: lint vet build test
|
||||
|
||||
build:
|
||||
go build github.com/kopia/kopia/...
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
// Format describes the format of object data.
|
||||
type Format struct {
|
||||
Version string `json:"version"`
|
||||
Hash string `json:"hash"`
|
||||
Encryption string `json:"encryption"`
|
||||
Secret []byte `json:"secret,omitempty"`
|
||||
|
||||
@@ -127,6 +127,9 @@ func NewObjectManager(
|
||||
f Format,
|
||||
options ...ObjectManagerOption,
|
||||
) (ObjectManager, error) {
|
||||
if f.Version != "1" {
|
||||
return nil, fmt.Errorf("unsupported repository version: %v", f.Version)
|
||||
}
|
||||
mgr := &objectManager{
|
||||
repository: r,
|
||||
maxInlineBlobSize: f.MaxInlineBlobSize,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
func testFormat() Format {
|
||||
return Format{
|
||||
Version: "1",
|
||||
MaxBlobSize: 200,
|
||||
MaxInlineBlobSize: 20,
|
||||
Hash: "md5",
|
||||
@@ -355,59 +356,65 @@ func TestEndToEndReadAndSeek(t *testing.T) {
|
||||
func TestFormats(t *testing.T) {
|
||||
cases := []struct {
|
||||
format Format
|
||||
hashes map[string]content.ObjectID
|
||||
oids map[string]content.ObjectID
|
||||
}{
|
||||
{
|
||||
format: Format{
|
||||
Hash: "md5",
|
||||
Version: "1",
|
||||
Hash: "md5",
|
||||
},
|
||||
hashes: map[string]content.ObjectID{
|
||||
oids: map[string]content.ObjectID{
|
||||
"": "Cd41d8cd98f00b204e9800998ecf8427e",
|
||||
"The quick brown fox jumps over the lazy dog": "C9e107d9d372bb6826bd81d3542a419d6",
|
||||
},
|
||||
},
|
||||
{
|
||||
format: Format{
|
||||
Hash: "hmac-md5",
|
||||
Version: "1",
|
||||
Hash: "hmac-md5",
|
||||
},
|
||||
hashes: map[string]content.ObjectID{
|
||||
oids: map[string]content.ObjectID{
|
||||
"": "C74e6f7298a9c2d168935f58c001bad88",
|
||||
"The quick brown fox jumps over the lazy dog": "Cad262969c53bc16032f160081c4a07a0",
|
||||
},
|
||||
},
|
||||
{
|
||||
format: Format{
|
||||
Hash: "hmac-md5",
|
||||
Secret: []byte("key"),
|
||||
Version: "1",
|
||||
Hash: "hmac-md5",
|
||||
Secret: []byte("key"),
|
||||
},
|
||||
hashes: map[string]content.ObjectID{
|
||||
oids: map[string]content.ObjectID{
|
||||
"The quick brown fox jumps over the lazy dog": "C80070713463e7749b90c2dc24911e275",
|
||||
},
|
||||
},
|
||||
{
|
||||
format: Format{
|
||||
Hash: "hmac-sha1",
|
||||
Secret: []byte("key"),
|
||||
Version: "1",
|
||||
Hash: "hmac-sha1",
|
||||
Secret: []byte("key"),
|
||||
},
|
||||
hashes: map[string]content.ObjectID{
|
||||
oids: map[string]content.ObjectID{
|
||||
"The quick brown fox jumps over the lazy dog": "Cde7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9",
|
||||
},
|
||||
},
|
||||
{
|
||||
format: Format{
|
||||
Hash: "hmac-sha256",
|
||||
Secret: []byte("key"),
|
||||
Version: "1",
|
||||
Hash: "hmac-sha256",
|
||||
Secret: []byte("key"),
|
||||
},
|
||||
hashes: map[string]content.ObjectID{
|
||||
oids: map[string]content.ObjectID{
|
||||
"The quick brown fox jumps over the lazy dog": "Cf7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8",
|
||||
},
|
||||
},
|
||||
{
|
||||
format: Format{
|
||||
Hash: "hmac-sha512",
|
||||
Secret: []byte("key"),
|
||||
Version: "1",
|
||||
Hash: "hmac-sha512",
|
||||
Secret: []byte("key"),
|
||||
},
|
||||
hashes: map[string]content.ObjectID{
|
||||
oids: map[string]content.ObjectID{
|
||||
"The quick brown fox jumps over the lazy dog": "Cb42af09057bac1e2d41708e48a902e09b5ff7f12ab428a4fe86653c73dd248fb82f948a549f7b791a5b41915ee4d1ec3935357e4e2317250d0372afa2ebeeb3a",
|
||||
},
|
||||
},
|
||||
@@ -423,7 +430,7 @@ func TestFormats(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
for k, v := range c.hashes {
|
||||
for k, v := range c.oids {
|
||||
w := mgr.NewWriter()
|
||||
w.Write([]byte(k))
|
||||
oid, err := w.Result(true)
|
||||
|
||||
Reference in New Issue
Block a user