mirror of
https://github.com/restic/restic.git
synced 2025-08-13 05:17:42 +00:00
Use "pack file" instead of "data file" (#2885)
- changed variable names, especially changed DataFile into PackFile - changed in some comments - always use "pack file" in docu
This commit is contained in:
@@ -383,7 +383,7 @@ func (be *Backend) removeKeys(ctx context.Context, t restic.FileType) error {
|
||||
// Delete removes all restic keys in the bucket. It will not remove the bucket itself.
|
||||
func (be *Backend) Delete(ctx context.Context) error {
|
||||
alltypes := []restic.FileType{
|
||||
restic.DataFile,
|
||||
restic.PackFile,
|
||||
restic.KeyFile,
|
||||
restic.LockFile,
|
||||
restic.SnapshotFile,
|
||||
|
@@ -172,7 +172,7 @@ func TestUploadLargeFile(t *testing.T) {
|
||||
|
||||
data := rtest.Random(23, 300*1024*1024)
|
||||
id := restic.Hash(data)
|
||||
h := restic.Handle{Name: id.String(), Type: restic.DataFile}
|
||||
h := restic.Handle{Name: id.String(), Type: restic.PackFile}
|
||||
|
||||
t.Logf("hash of %d bytes: %v", len(data), id)
|
||||
|
||||
|
@@ -308,7 +308,7 @@ func (be *b2Backend) removeKeys(ctx context.Context, t restic.FileType) error {
|
||||
// Delete removes all restic keys in the bucket. It will not remove the bucket itself.
|
||||
func (be *b2Backend) Delete(ctx context.Context) error {
|
||||
alltypes := []restic.FileType{
|
||||
restic.DataFile,
|
||||
restic.PackFile,
|
||||
restic.KeyFile,
|
||||
restic.LockFile,
|
||||
restic.SnapshotFile,
|
||||
|
@@ -78,7 +78,7 @@ func TestBackendListRetry(t *testing.T) {
|
||||
}
|
||||
|
||||
var listed []string
|
||||
err := retryBackend.List(context.TODO(), restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := retryBackend.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
listed = append(listed, fi.Name)
|
||||
return nil
|
||||
})
|
||||
@@ -112,7 +112,7 @@ func TestBackendListRetryErrorFn(t *testing.T) {
|
||||
|
||||
var listed []string
|
||||
run := 0
|
||||
err := retryBackend.List(context.TODO(), restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := retryBackend.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
t.Logf("fn called for %v", fi.Name)
|
||||
run++
|
||||
// return an error for the third item in the list
|
||||
@@ -168,7 +168,7 @@ func TestBackendListRetryErrorBackend(t *testing.T) {
|
||||
}
|
||||
|
||||
var listed []string
|
||||
err := retryBackend.List(context.TODO(), restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := retryBackend.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
t.Logf("fn called for %v", fi.Name)
|
||||
listed = append(listed, fi.Name)
|
||||
return nil
|
||||
|
@@ -439,7 +439,7 @@ func (be *Backend) removeKeys(ctx context.Context, t restic.FileType) error {
|
||||
// Delete removes all restic keys in the bucket. It will not remove the bucket itself.
|
||||
func (be *Backend) Delete(ctx context.Context) error {
|
||||
alltypes := []restic.FileType{
|
||||
restic.DataFile,
|
||||
restic.PackFile,
|
||||
restic.KeyFile,
|
||||
restic.LockFile,
|
||||
restic.SnapshotFile,
|
||||
|
@@ -16,7 +16,7 @@ type DefaultLayout struct {
|
||||
}
|
||||
|
||||
var defaultLayoutPaths = map[restic.FileType]string{
|
||||
restic.DataFile: "data",
|
||||
restic.PackFile: "data",
|
||||
restic.SnapshotFile: "snapshots",
|
||||
restic.IndexFile: "index",
|
||||
restic.LockFile: "locks",
|
||||
@@ -36,7 +36,7 @@ func (l *DefaultLayout) Name() string {
|
||||
func (l *DefaultLayout) Dirname(h restic.Handle) string {
|
||||
p := defaultLayoutPaths[h.Type]
|
||||
|
||||
if h.Type == restic.DataFile && len(h.Name) > 2 {
|
||||
if h.Type == restic.PackFile && len(h.Name) > 2 {
|
||||
p = l.Join(p, h.Name[:2]) + "/"
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func (l *DefaultLayout) Paths() (dirs []string) {
|
||||
// also add subdirs
|
||||
for i := 0; i < 256; i++ {
|
||||
subdir := hex.EncodeToString([]byte{byte(i)})
|
||||
dirs = append(dirs, l.Join(l.Path, defaultLayoutPaths[restic.DataFile], subdir))
|
||||
dirs = append(dirs, l.Join(l.Path, defaultLayoutPaths[restic.PackFile], subdir))
|
||||
}
|
||||
|
||||
return dirs
|
||||
@@ -70,7 +70,7 @@ func (l *DefaultLayout) Paths() (dirs []string) {
|
||||
|
||||
// Basedir returns the base dir name for type t.
|
||||
func (l *DefaultLayout) Basedir(t restic.FileType) (dirname string, subdirs bool) {
|
||||
if t == restic.DataFile {
|
||||
if t == restic.PackFile {
|
||||
subdirs = true
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ type S3LegacyLayout struct {
|
||||
}
|
||||
|
||||
var s3LayoutPaths = map[restic.FileType]string{
|
||||
restic.DataFile: "data",
|
||||
restic.PackFile: "data",
|
||||
restic.SnapshotFile: "snapshot",
|
||||
restic.IndexFile: "index",
|
||||
restic.LockFile: "lock",
|
||||
|
@@ -25,7 +25,7 @@ func TestDefaultLayout(t *testing.T) {
|
||||
{
|
||||
tempdir,
|
||||
filepath.Join,
|
||||
restic.Handle{Type: restic.DataFile, Name: "0123456"},
|
||||
restic.Handle{Type: restic.PackFile, Name: "0123456"},
|
||||
filepath.Join(tempdir, "data", "01", "0123456"),
|
||||
},
|
||||
{
|
||||
@@ -61,7 +61,7 @@ func TestDefaultLayout(t *testing.T) {
|
||||
{
|
||||
"",
|
||||
path.Join,
|
||||
restic.Handle{Type: restic.DataFile, Name: "0123456"},
|
||||
restic.Handle{Type: restic.PackFile, Name: "0123456"},
|
||||
"data/01/0123456",
|
||||
},
|
||||
{
|
||||
@@ -148,7 +148,7 @@ func TestRESTLayout(t *testing.T) {
|
||||
filename string
|
||||
}{
|
||||
{
|
||||
restic.Handle{Type: restic.DataFile, Name: "0123456"},
|
||||
restic.Handle{Type: restic.PackFile, Name: "0123456"},
|
||||
filepath.Join(path, "data", "0123456"),
|
||||
},
|
||||
{
|
||||
@@ -216,7 +216,7 @@ func TestRESTLayoutURLs(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
&RESTLayout{URL: "https://hostname.foo", Path: "", Join: path.Join},
|
||||
restic.Handle{Type: restic.DataFile, Name: "foobar"},
|
||||
restic.Handle{Type: restic.PackFile, Name: "foobar"},
|
||||
"https://hostname.foo/data/foobar",
|
||||
"https://hostname.foo/data/",
|
||||
},
|
||||
@@ -234,7 +234,7 @@ func TestRESTLayoutURLs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
&S3LegacyLayout{URL: "https://hostname.foo", Path: "/", Join: path.Join},
|
||||
restic.Handle{Type: restic.DataFile, Name: "foobar"},
|
||||
restic.Handle{Type: restic.PackFile, Name: "foobar"},
|
||||
"https://hostname.foo/data/foobar",
|
||||
"https://hostname.foo/data/",
|
||||
},
|
||||
@@ -252,7 +252,7 @@ func TestRESTLayoutURLs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
&S3LegacyLayout{URL: "", Path: "", Join: path.Join},
|
||||
restic.Handle{Type: restic.DataFile, Name: "foobar"},
|
||||
restic.Handle{Type: restic.PackFile, Name: "foobar"},
|
||||
"data/foobar",
|
||||
"data/",
|
||||
},
|
||||
@@ -294,7 +294,7 @@ func TestS3LegacyLayout(t *testing.T) {
|
||||
filename string
|
||||
}{
|
||||
{
|
||||
restic.Handle{Type: restic.DataFile, Name: "0123456"},
|
||||
restic.Handle{Type: restic.PackFile, Name: "0123456"},
|
||||
filepath.Join(path, "data", "0123456"),
|
||||
},
|
||||
{
|
||||
@@ -419,8 +419,8 @@ func TestParseLayout(t *testing.T) {
|
||||
}
|
||||
|
||||
// test that the functions work (and don't panic)
|
||||
_ = layout.Dirname(restic.Handle{Type: restic.DataFile})
|
||||
_ = layout.Filename(restic.Handle{Type: restic.DataFile, Name: "1234"})
|
||||
_ = layout.Dirname(restic.Handle{Type: restic.PackFile})
|
||||
_ = layout.Filename(restic.Handle{Type: restic.PackFile, Name: "1234"})
|
||||
_ = layout.Paths()
|
||||
|
||||
layoutName := fmt.Sprintf("%T", layout)
|
||||
|
@@ -17,7 +17,7 @@ func TestLayout(t *testing.T) {
|
||||
filename string
|
||||
layout string
|
||||
failureExpected bool
|
||||
datafiles map[string]bool
|
||||
packfiles map[string]bool
|
||||
}{
|
||||
{"repo-layout-default.tar.gz", "", false, map[string]bool{
|
||||
"aa464e9fd598fe4202492ee317ffa728e82fa83a1de1a61996e5bd2d6651646c": false,
|
||||
@@ -48,9 +48,9 @@ func TestLayout(t *testing.T) {
|
||||
t.Fatalf("Open() returned nil but no error")
|
||||
}
|
||||
|
||||
datafiles := make(map[string]bool)
|
||||
err = be.List(context.TODO(), restic.DataFile, func(fi restic.FileInfo) error {
|
||||
datafiles[fi.Name] = false
|
||||
packs := make(map[string]bool)
|
||||
err = be.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
packs[fi.Name] = false
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -58,19 +58,19 @@ func TestLayout(t *testing.T) {
|
||||
t.Fatalf("List() returned error %v", err)
|
||||
}
|
||||
|
||||
if len(datafiles) == 0 {
|
||||
t.Errorf("List() returned zero data files")
|
||||
if len(packs) == 0 {
|
||||
t.Errorf("List() returned zero pack files")
|
||||
}
|
||||
|
||||
for id := range test.datafiles {
|
||||
if _, ok := datafiles[id]; !ok {
|
||||
t.Errorf("datafile with id %v not found", id)
|
||||
for id := range test.packfiles {
|
||||
if _, ok := packs[id]; !ok {
|
||||
t.Errorf("packfile with id %v not found", id)
|
||||
}
|
||||
|
||||
datafiles[id] = true
|
||||
packs[id] = true
|
||||
}
|
||||
|
||||
for id, v := range datafiles {
|
||||
for id, v := range packs {
|
||||
if !v {
|
||||
t.Errorf("unexpected id %v found", id)
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ func TestRcloneExit(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
_, err = be.Stat(context.TODO(), restic.Handle{
|
||||
Name: "foo",
|
||||
Type: restic.DataFile,
|
||||
Type: restic.PackFile,
|
||||
})
|
||||
rtest.Assert(t, err != nil, "expected an error")
|
||||
}
|
||||
|
@@ -442,7 +442,7 @@ func (b *Backend) removeKeys(ctx context.Context, t restic.FileType) error {
|
||||
// Delete removes all data in the backend.
|
||||
func (b *Backend) Delete(ctx context.Context) error {
|
||||
alltypes := []restic.FileType{
|
||||
restic.DataFile,
|
||||
restic.PackFile,
|
||||
restic.KeyFile,
|
||||
restic.LockFile,
|
||||
restic.SnapshotFile,
|
||||
|
@@ -123,7 +123,7 @@ func TestListAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
var list []restic.FileInfo
|
||||
err = be.List(context.TODO(), restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err = be.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
list = append(list, fi)
|
||||
return nil
|
||||
})
|
||||
|
@@ -445,7 +445,7 @@ func (be *Backend) List(ctx context.Context, t restic.FileType, fn func(restic.F
|
||||
|
||||
// Remove keys for a specified backend type.
|
||||
func (be *Backend) removeKeys(ctx context.Context, t restic.FileType) error {
|
||||
return be.List(ctx, restic.DataFile, func(fi restic.FileInfo) error {
|
||||
return be.List(ctx, restic.PackFile, func(fi restic.FileInfo) error {
|
||||
return be.Remove(ctx, restic.Handle{Type: t, Name: fi.Name})
|
||||
})
|
||||
}
|
||||
@@ -453,7 +453,7 @@ func (be *Backend) removeKeys(ctx context.Context, t restic.FileType) error {
|
||||
// Delete removes all restic keys in the bucket. It will not remove the bucket itself.
|
||||
func (be *Backend) Delete(ctx context.Context) error {
|
||||
alltypes := []restic.FileType{
|
||||
restic.DataFile,
|
||||
restic.PackFile,
|
||||
restic.KeyFile,
|
||||
restic.LockFile,
|
||||
restic.SnapshotFile,
|
||||
|
@@ -23,7 +23,7 @@ func TestLayout(t *testing.T) {
|
||||
filename string
|
||||
layout string
|
||||
failureExpected bool
|
||||
datafiles map[string]bool
|
||||
packfiles map[string]bool
|
||||
}{
|
||||
{"repo-layout-default.tar.gz", "", false, map[string]bool{
|
||||
"aa464e9fd598fe4202492ee317ffa728e82fa83a1de1a61996e5bd2d6651646c": false,
|
||||
@@ -55,26 +55,26 @@ func TestLayout(t *testing.T) {
|
||||
t.Fatalf("Open() returned nil but no error")
|
||||
}
|
||||
|
||||
datafiles := make(map[string]bool)
|
||||
err = be.List(context.TODO(), restic.DataFile, func(fi restic.FileInfo) error {
|
||||
datafiles[fi.Name] = false
|
||||
packs := make(map[string]bool)
|
||||
err = be.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
packs[fi.Name] = false
|
||||
return nil
|
||||
})
|
||||
rtest.OK(t, err)
|
||||
|
||||
if len(datafiles) == 0 {
|
||||
t.Errorf("List() returned zero data files")
|
||||
if len(packs) == 0 {
|
||||
t.Errorf("List() returned zero pack files")
|
||||
}
|
||||
|
||||
for id := range test.datafiles {
|
||||
if _, ok := datafiles[id]; !ok {
|
||||
t.Errorf("datafile with id %v not found", id)
|
||||
for id := range test.packfiles {
|
||||
if _, ok := packs[id]; !ok {
|
||||
t.Errorf("packfile with id %v not found", id)
|
||||
}
|
||||
|
||||
datafiles[id] = true
|
||||
packs[id] = true
|
||||
}
|
||||
|
||||
for id, v := range datafiles {
|
||||
for id, v := range packs {
|
||||
if !v {
|
||||
t.Errorf("unexpected id %v found", id)
|
||||
}
|
||||
|
@@ -298,7 +298,7 @@ func (be *beSwift) IsNotExist(err error) bool {
|
||||
// It will not remove the container itself.
|
||||
func (be *beSwift) Delete(ctx context.Context) error {
|
||||
alltypes := []restic.FileType{
|
||||
restic.DataFile,
|
||||
restic.PackFile,
|
||||
restic.KeyFile,
|
||||
restic.LockFile,
|
||||
restic.SnapshotFile,
|
||||
|
@@ -13,7 +13,7 @@ import (
|
||||
func saveRandomFile(t testing.TB, be restic.Backend, length int) ([]byte, restic.Handle) {
|
||||
data := test.Random(23, length)
|
||||
id := restic.Hash(data)
|
||||
handle := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
||||
handle := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
||||
err := be.Save(context.TODO(), handle, restic.NewByteReader(data))
|
||||
if err != nil {
|
||||
t.Fatalf("Save() error: %+v", err)
|
||||
@@ -146,7 +146,7 @@ func (s *Suite) BenchmarkSave(t *testing.B) {
|
||||
length := 1<<24 + 2123
|
||||
data := test.Random(23, length)
|
||||
id := restic.Hash(data)
|
||||
handle := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
||||
handle := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
||||
|
||||
rd := restic.NewByteReader(data)
|
||||
t.SetBytes(int64(length))
|
||||
|
@@ -123,7 +123,7 @@ func (s *Suite) TestLoad(t *testing.T) {
|
||||
t.Fatalf("Load() did not return an error for invalid handle")
|
||||
}
|
||||
|
||||
err = testLoad(b, restic.Handle{Type: restic.DataFile, Name: "foobar"}, 0, 0)
|
||||
err = testLoad(b, restic.Handle{Type: restic.PackFile, Name: "foobar"}, 0, 0)
|
||||
if err == nil {
|
||||
t.Fatalf("Load() did not return an error for non-existing blob")
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func (s *Suite) TestLoad(t *testing.T) {
|
||||
data := test.Random(23, length)
|
||||
id := restic.Hash(data)
|
||||
|
||||
handle := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
||||
handle := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
||||
err = b.Save(context.TODO(), handle, restic.NewByteReader(data))
|
||||
if err != nil {
|
||||
t.Fatalf("Save() error: %+v", err)
|
||||
@@ -236,7 +236,7 @@ func (s *Suite) TestList(t *testing.T) {
|
||||
|
||||
// Check that the backend is empty to start with
|
||||
var found []string
|
||||
err := b.List(context.TODO(), restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := b.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
found = append(found, fi.Name)
|
||||
return nil
|
||||
})
|
||||
@@ -252,7 +252,7 @@ func (s *Suite) TestList(t *testing.T) {
|
||||
for i := 0; i < numTestFiles; i++ {
|
||||
data := test.Random(rand.Int(), rand.Intn(100)+55)
|
||||
id := restic.Hash(data)
|
||||
h := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
||||
h := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
||||
err := b.Save(context.TODO(), h, restic.NewByteReader(data))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -281,7 +281,7 @@ func (s *Suite) TestList(t *testing.T) {
|
||||
s.SetListMaxItems(test.maxItems)
|
||||
}
|
||||
|
||||
err := b.List(context.TODO(), restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := b.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
id, err := restic.ParseID(fi.Name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -319,7 +319,7 @@ func (s *Suite) TestList(t *testing.T) {
|
||||
t.Logf("remove %d files", numTestFiles)
|
||||
handles := make([]restic.Handle, 0, len(list1))
|
||||
for id := range list1 {
|
||||
handles = append(handles, restic.Handle{Type: restic.DataFile, Name: id.String()})
|
||||
handles = append(handles, restic.Handle{Type: restic.PackFile, Name: id.String()})
|
||||
}
|
||||
|
||||
err = s.delayedRemove(t, b, handles...)
|
||||
@@ -342,7 +342,7 @@ func (s *Suite) TestListCancel(t *testing.T) {
|
||||
for i := 0; i < numTestFiles; i++ {
|
||||
data := []byte(fmt.Sprintf("random test blob %v", i))
|
||||
id := restic.Hash(data)
|
||||
h := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
||||
h := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
||||
err := b.Save(context.TODO(), h, restic.NewByteReader(data))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -355,7 +355,7 @@ func (s *Suite) TestListCancel(t *testing.T) {
|
||||
cancel()
|
||||
|
||||
// pass in a cancelled context
|
||||
err := b.List(ctx, restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := b.List(ctx, restic.PackFile, func(fi restic.FileInfo) error {
|
||||
t.Errorf("got FileInfo %v for cancelled context", fi)
|
||||
return nil
|
||||
})
|
||||
@@ -370,7 +370,7 @@ func (s *Suite) TestListCancel(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
i := 0
|
||||
err := b.List(ctx, restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := b.List(ctx, restic.PackFile, func(fi restic.FileInfo) error {
|
||||
i++
|
||||
// cancel the context on the first file
|
||||
if i == 1 {
|
||||
@@ -393,7 +393,7 @@ func (s *Suite) TestListCancel(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
i := 0
|
||||
err := b.List(ctx, restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := b.List(ctx, restic.PackFile, func(fi restic.FileInfo) error {
|
||||
// cancel the context at the last file
|
||||
i++
|
||||
if i == numTestFiles {
|
||||
@@ -420,7 +420,7 @@ func (s *Suite) TestListCancel(t *testing.T) {
|
||||
|
||||
i := 0
|
||||
// pass in a context with a timeout
|
||||
err := b.List(ctxTimeout, restic.DataFile, func(fi restic.FileInfo) error {
|
||||
err := b.List(ctxTimeout, restic.PackFile, func(fi restic.FileInfo) error {
|
||||
i++
|
||||
|
||||
// wait until the context is cancelled
|
||||
@@ -483,7 +483,7 @@ func (s *Suite) TestSave(t *testing.T) {
|
||||
copy(id[:], data)
|
||||
|
||||
h := restic.Handle{
|
||||
Type: restic.DataFile,
|
||||
Type: restic.PackFile,
|
||||
Name: fmt.Sprintf("%s-%d", id, i),
|
||||
}
|
||||
err := b.Save(context.TODO(), h, restic.NewByteReader(data))
|
||||
@@ -534,7 +534,7 @@ func (s *Suite) TestSave(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
h := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
||||
h := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
||||
|
||||
// wrap the tempfile in an errorCloser, so we can detect if the backend
|
||||
// closes the reader
|
||||
@@ -575,7 +575,7 @@ func (s *Suite) TestSaveFilenames(t *testing.T) {
|
||||
defer s.close(t, b)
|
||||
|
||||
for i, test := range filenameTests {
|
||||
h := restic.Handle{Name: test.name, Type: restic.DataFile}
|
||||
h := restic.Handle{Name: test.name, Type: restic.PackFile}
|
||||
err := b.Save(context.TODO(), h, restic.NewByteReader([]byte(test.data)))
|
||||
if err != nil {
|
||||
t.Errorf("test %d failed: Save() returned %+v", i, err)
|
||||
@@ -698,7 +698,7 @@ func (s *Suite) TestBackend(t *testing.T) {
|
||||
defer s.close(t, b)
|
||||
|
||||
for _, tpe := range []restic.FileType{
|
||||
restic.DataFile, restic.KeyFile, restic.LockFile,
|
||||
restic.PackFile, restic.KeyFile, restic.LockFile,
|
||||
restic.SnapshotFile, restic.IndexFile,
|
||||
} {
|
||||
// detect non-existing files
|
||||
|
@@ -25,11 +25,11 @@ func TestLoadAll(t *testing.T) {
|
||||
data := rtest.Random(23+i, rand.Intn(MiB)+500*KiB)
|
||||
|
||||
id := restic.Hash(data)
|
||||
h := restic.Handle{Name: id.String(), Type: restic.DataFile}
|
||||
h := restic.Handle{Name: id.String(), Type: restic.PackFile}
|
||||
err := b.Save(context.TODO(), h, restic.NewByteReader(data))
|
||||
rtest.OK(t, err)
|
||||
|
||||
buf, err := backend.LoadAll(context.TODO(), buf, b, restic.Handle{Type: restic.DataFile, Name: id.String()})
|
||||
buf, err := backend.LoadAll(context.TODO(), buf, b, restic.Handle{Type: restic.PackFile, Name: id.String()})
|
||||
rtest.OK(t, err)
|
||||
|
||||
if len(buf) != len(data) {
|
||||
@@ -46,7 +46,7 @@ func TestLoadAll(t *testing.T) {
|
||||
|
||||
func save(t testing.TB, be restic.Backend, buf []byte) restic.Handle {
|
||||
id := restic.Hash(buf)
|
||||
h := restic.Handle{Name: id.String(), Type: restic.DataFile}
|
||||
h := restic.Handle{Name: id.String(), Type: restic.PackFile}
|
||||
err := be.Save(context.TODO(), h, restic.NewByteReader(buf))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -121,7 +121,7 @@ func (rd *mockReader) Close() error {
|
||||
|
||||
func TestDefaultLoad(t *testing.T) {
|
||||
|
||||
h := restic.Handle{Name: "id", Type: restic.DataFile}
|
||||
h := restic.Handle{Name: "id", Type: restic.PackFile}
|
||||
rd := &mockReader{}
|
||||
|
||||
// happy case, assert correct parameters are passed around and content stream is closed
|
||||
|
Reference in New Issue
Block a user