diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index 2fafee92f..01bb0b14a 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -708,7 +708,7 @@ var optimizeTests = []struct { "a13c11e582b77a693dd75ab4e3a3ba96538a056594a4b9076e4cacebe6e06d43", }, { - filepath.Join("..", "..", "repository", "testdata", "old-index-repo.tar.gz"), + filepath.Join("testdata", "old-index-repo.tar.gz"), "", }, } diff --git a/repository/testdata/old-index-repo.tar.gz b/cmd/restic/testdata/old-index-repo.tar.gz similarity index 100% rename from repository/testdata/old-index-repo.tar.gz rename to cmd/restic/testdata/old-index-repo.tar.gz diff --git a/repository/index.go b/repository/index.go index cd4e6e9dd..4694c5d13 100644 --- a/repository/index.go +++ b/repository/index.go @@ -539,32 +539,6 @@ func DecodeOldIndex(rd io.Reader) (idx *Index, err error) { return idx, err } -// ConvertIndexes loads all indexes from the repo and converts them to the new -// format (if necessary). When the conversion is succcessful, the old indexes -// are removed. -func ConvertIndexes(repo *Repository) error { - debug.Log("ConvertIndexes", "start") - done := make(chan struct{}) - defer close(done) - - for id := range repo.List(backend.Index, done) { - debug.Log("ConvertIndexes", "checking index %v", id.Str()) - - newID, err := ConvertIndex(repo, id) - if err != nil { - debug.Log("ConvertIndexes", "Converting index %v returns error: %v", id.Str(), err) - return err - } - - if id != newID { - debug.Log("ConvertIndexes", "index %v converted to new format as %v", id.Str(), newID.Str()) - } - } - - debug.Log("ConvertIndexes", "done") - return nil -} - // LoadIndexWithDecoder loads the index and decodes it with fn. func LoadIndexWithDecoder(repo *Repository, id string, fn func(io.Reader) (*Index, error)) (*Index, error) { debug.Log("LoadIndexWithDecoder", "Loading index %v", id[:8]) diff --git a/repository/index_test.go b/repository/index_test.go index db4d79345..4a6f270fd 100644 --- a/repository/index_test.go +++ b/repository/index_test.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/rand" "io" - "path/filepath" "testing" "github.com/restic/restic/backend" @@ -323,56 +322,6 @@ func TestIndexUnserializeOld(t *testing.T) { Equals(t, 0, len(idx.Supersedes())) } -var oldIndexTestRepo = filepath.Join("testdata", "old-index-repo.tar.gz") - -func TestConvertIndex(t *testing.T) { - WithTestEnvironment(t, oldIndexTestRepo, func(repodir string) { - repo := OpenLocalRepo(t, repodir) - - old := make(map[backend.ID]*repository.Index) - for id := range repo.List(backend.Index, nil) { - idx, err := repository.LoadIndex(repo, id.String()) - OK(t, err) - old[id] = idx - } - - OK(t, repository.ConvertIndexes(repo)) - - for id := range repo.List(backend.Index, nil) { - idx, err := repository.LoadIndexWithDecoder(repo, id.String(), repository.DecodeIndex) - OK(t, err) - - Assert(t, len(idx.Supersedes()) == 1, - "Expected index %v to supersed exactly one index, got %v", id, idx.Supersedes()) - - oldIndexID := idx.Supersedes()[0] - - oldIndex, ok := old[oldIndexID] - Assert(t, ok, - "Index %v superseds %v, but that wasn't found in the old index map", id.Str(), oldIndexID.Str()) - - Assert(t, idx.Count(pack.Data) == oldIndex.Count(pack.Data), - "Index %v count blobs %v: %v != %v", id.Str(), pack.Data, idx.Count(pack.Data), oldIndex.Count(pack.Data)) - Assert(t, idx.Count(pack.Tree) == oldIndex.Count(pack.Tree), - "Index %v count blobs %v: %v != %v", id.Str(), pack.Tree, idx.Count(pack.Tree), oldIndex.Count(pack.Tree)) - - for packedBlob := range idx.Each(nil) { - blob, err := oldIndex.Lookup(packedBlob.ID) - OK(t, err) - - Assert(t, blob.PackID == packedBlob.PackID, - "Check blob %v: pack ID %v != %v", packedBlob.ID, blob.PackID, packedBlob.PackID) - Assert(t, blob.Type == packedBlob.Type, - "Check blob %v: Type %v != %v", packedBlob.ID, blob.Type, packedBlob.Type) - Assert(t, blob.Offset == packedBlob.Offset, - "Check blob %v: Type %v != %v", packedBlob.ID, blob.Offset, packedBlob.Offset) - Assert(t, blob.Length == packedBlob.Length, - "Check blob %v: Type %v != %v", packedBlob.ID, blob.Length, packedBlob.Length) - } - } - }) -} - func TestIndexPacks(t *testing.T) { idx := repository.NewIndex() packs := backend.NewIDSet()