diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-21 19:01:51 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-21 19:01:51 +0200 |
commit | 0789fd07f6b7ac9eaf51bf349043b9002f0965f6 (patch) | |
tree | c54d3058062f80049e7fb4a81ab29aac04a3d546 | |
parent | 79b4564d77de71abffc82406561cc02b762c29d3 (diff) | |
download | dna-backup-0789fd07f6b7ac9eaf51bf349043b9002f0965f6.tar.gz dna-backup-0789fd07f6b7ac9eaf51bf349043b9002f0965f6.zip |
define name of gob registered structs
also store uncompressed delta for now and add wrapper parameter
-rw-r--r-- | repo.go | 14 | ||||
-rw-r--r-- | testdata/repo_8k/00000/recipe | bin | 2631 -> 6783 bytes | |||
-rw-r--r-- | testdata/repo_8k_zlib/00000/recipe | bin | 2631 -> 6783 bytes |
3 files changed, 7 insertions, 7 deletions
@@ -51,9 +51,9 @@ import ( func init() { // register chunk structs for encoding/decoding using gob - gob.Register(&StoredChunk{}) - gob.Register(&TempChunk{}) - gob.Register(&DeltaChunk{}) + gob.RegisterName("*dna-backup.StoredChunk", &StoredChunk{}) + gob.RegisterName("*dna-backup.TempChunk", &TempChunk{}) + gob.RegisterName("*dna-backup.DeltaChunk", &DeltaChunk{}) } type FingerprintMap map[uint64]*ChunkId @@ -297,11 +297,11 @@ func loadBasicStruct(path string, wrapper utils.ReadWrapper, obj interface{}) { } } -func (r *Repo) loadDeltas(versions []string, name string) (ret slice.Slice) { +func (r *Repo) loadDeltas(versions []string, wrapper utils.ReadWrapper, name string) (ret slice.Slice) { for _, v := range versions { path := filepath.Join(v, name) var delta slice.Delta - loadBasicStruct(path, utils.ZlibReader, &delta) + loadBasicStruct(path, wrapper, &delta) ret = slice.Patch(ret, delta) } return @@ -681,11 +681,11 @@ func slice2recipe(s slice.Slice) (ret []Chunk) { func (r *Repo) storeRecipe(version int, recipe []Chunk) { dest := filepath.Join(r.path, fmt.Sprintf(versionFmt, version), recipeName) delta := slice.Diff(recipe2slice(r.recipe), recipe2slice(recipe)) - storeBasicStruct(dest, utils.ZlibWriter, delta) + storeBasicStruct(dest, utils.NopWriteWrapper, delta) } func (r *Repo) loadRecipes(versions []string) { - recipe := slice2recipe(r.loadDeltas(versions, recipeName)) + recipe := slice2recipe(r.loadDeltas(versions, utils.NopReadWrapper, recipeName)) for _, c := range recipe { if rc, isRepo := c.(RepoChunk); isRepo { rc.SetRepo(r) diff --git a/testdata/repo_8k/00000/recipe b/testdata/repo_8k/00000/recipe Binary files differindex 8e91b3b..66bde3d 100644 --- a/testdata/repo_8k/00000/recipe +++ b/testdata/repo_8k/00000/recipe diff --git a/testdata/repo_8k_zlib/00000/recipe b/testdata/repo_8k_zlib/00000/recipe Binary files differindex 8e91b3b..66bde3d 100644 --- a/testdata/repo_8k_zlib/00000/recipe +++ b/testdata/repo_8k_zlib/00000/recipe |