From 61cade62229a3537ff1a8381eac59a690232328b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 15 May 2017 21:58:03 +0200 Subject: [PATCH] Rename layout s3 -> s3legacy --- src/restic/backend/layout.go | 8 ++++---- .../{layout_s3.go => layout_s3legacy.go} | 14 ++++++------- src/restic/backend/layout_test.go | 20 +++++++++---------- src/restic/backend/s3/s3.go | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) rename src/restic/backend/{layout_s3.go => layout_s3legacy.go} (74%) diff --git a/src/restic/backend/layout.go b/src/restic/backend/layout.go index de72f07d4..1fa110760 100644 --- a/src/restic/backend/layout.go +++ b/src/restic/backend/layout.go @@ -170,7 +170,7 @@ func DetectLayout(repo Filesystem, dir string) (Layout, error) { if foundKeyFile && foundDataFile && !foundKeysFile && !foundDataSubdirFile { debug.Log("found s3 layout at %v", dir) - return &S3Layout{ + return &S3LegacyLayout{ Path: dir, Join: repo.Join, }, nil @@ -195,8 +195,8 @@ func ParseLayout(repo Filesystem, layout, defaultLayout, path string) (l Layout, Path: path, Join: repo.Join, } - case "s3": - l = &S3Layout{ + case "s3legacy": + l = &S3LegacyLayout{ Path: path, Join: repo.Join, } @@ -214,7 +214,7 @@ func ParseLayout(repo Filesystem, layout, defaultLayout, path string) (l Layout, } debug.Log("layout detected: %v", l) default: - return nil, errors.Errorf("unknown backend layout string %q, may be one of: default, cloud, s3", layout) + return nil, errors.Errorf("unknown backend layout string %q, may be one of: default, cloud, s3legacy", layout) } return l, nil diff --git a/src/restic/backend/layout_s3.go b/src/restic/backend/layout_s3legacy.go similarity index 74% rename from src/restic/backend/layout_s3.go rename to src/restic/backend/layout_s3legacy.go index 91273d63a..601d29bc5 100644 --- a/src/restic/backend/layout_s3.go +++ b/src/restic/backend/layout_s3legacy.go @@ -2,9 +2,9 @@ package backend import "restic" -// S3Layout implements the old layout used for s3 cloud storage backends, as +// S3LegacyLayout implements the old layout used for s3 cloud storage backends, as // described in the Design document. -type S3Layout struct { +type S3LegacyLayout struct { URL string Path string Join func(...string) string @@ -19,7 +19,7 @@ var s3LayoutPaths = map[restic.FileType]string{ } // join calls Join with the first empty elements removed. -func (l *S3Layout) join(url string, items ...string) string { +func (l *S3LegacyLayout) join(url string, items ...string) string { for len(items) > 0 && items[0] == "" { items = items[1:] } @@ -35,7 +35,7 @@ func (l *S3Layout) join(url string, items ...string) string { } // Dirname returns the directory path for a given file type and name. -func (l *S3Layout) Dirname(h restic.Handle) string { +func (l *S3LegacyLayout) Dirname(h restic.Handle) string { if h.Type == restic.ConfigFile { return l.URL + l.Join(l.Path, "/") } @@ -44,7 +44,7 @@ func (l *S3Layout) Dirname(h restic.Handle) string { } // Filename returns a path to a file, including its name. -func (l *S3Layout) Filename(h restic.Handle) string { +func (l *S3LegacyLayout) Filename(h restic.Handle) string { name := h.Name if h.Type == restic.ConfigFile { @@ -55,7 +55,7 @@ func (l *S3Layout) Filename(h restic.Handle) string { } // Paths returns all directory names -func (l *S3Layout) Paths() (dirs []string) { +func (l *S3LegacyLayout) Paths() (dirs []string) { for _, p := range s3LayoutPaths { dirs = append(dirs, l.Join(l.Path, p)) } @@ -63,6 +63,6 @@ func (l *S3Layout) Paths() (dirs []string) { } // Basedir returns the base dir name for type t. -func (l *S3Layout) Basedir(t restic.FileType) string { +func (l *S3LegacyLayout) Basedir(t restic.FileType) string { return l.Join(l.Path, s3LayoutPaths[t]) } diff --git a/src/restic/backend/layout_test.go b/src/restic/backend/layout_test.go index 606da3241..4c296f29e 100644 --- a/src/restic/backend/layout_test.go +++ b/src/restic/backend/layout_test.go @@ -173,37 +173,37 @@ func TestCloudLayoutURLs(t *testing.T) { "https://hostname.foo:1234/prefix/repo/", }, { - &S3Layout{URL: "https://hostname.foo", Path: "/", Join: path.Join}, + &S3LegacyLayout{URL: "https://hostname.foo", Path: "/", Join: path.Join}, restic.Handle{Type: restic.DataFile, Name: "foobar"}, "https://hostname.foo/data/foobar", "https://hostname.foo/data/", }, { - &S3Layout{URL: "https://hostname.foo:1234/prefix/repo", Path: "", Join: path.Join}, + &S3LegacyLayout{URL: "https://hostname.foo:1234/prefix/repo", Path: "", Join: path.Join}, restic.Handle{Type: restic.LockFile, Name: "foobar"}, "https://hostname.foo:1234/prefix/repo/lock/foobar", "https://hostname.foo:1234/prefix/repo/lock/", }, { - &S3Layout{URL: "https://hostname.foo:1234/prefix/repo", Path: "/", Join: path.Join}, + &S3LegacyLayout{URL: "https://hostname.foo:1234/prefix/repo", Path: "/", Join: path.Join}, restic.Handle{Type: restic.ConfigFile, Name: "foobar"}, "https://hostname.foo:1234/prefix/repo/config", "https://hostname.foo:1234/prefix/repo/", }, { - &S3Layout{URL: "", Path: "", Join: path.Join}, + &S3LegacyLayout{URL: "", Path: "", Join: path.Join}, restic.Handle{Type: restic.DataFile, Name: "foobar"}, "data/foobar", "data/", }, { - &S3Layout{URL: "", Path: "", Join: path.Join}, + &S3LegacyLayout{URL: "", Path: "", Join: path.Join}, restic.Handle{Type: restic.LockFile, Name: "foobar"}, "lock/foobar", "lock/", }, { - &S3Layout{URL: "", Path: "/", Join: path.Join}, + &S3LegacyLayout{URL: "", Path: "/", Join: path.Join}, restic.Handle{Type: restic.ConfigFile, Name: "foobar"}, "/config", "/", @@ -225,7 +225,7 @@ func TestCloudLayoutURLs(t *testing.T) { } } -func TestS3Layout(t *testing.T) { +func TestS3LegacyLayout(t *testing.T) { path, cleanup := TempDir(t) defer cleanup() @@ -259,7 +259,7 @@ func TestS3Layout(t *testing.T) { }, } - l := &S3Layout{ + l := &S3LegacyLayout{ Path: path, Join: filepath.Join, } @@ -303,7 +303,7 @@ func TestDetectLayout(t *testing.T) { }{ {"repo-layout-local.tar.gz", "*backend.DefaultLayout"}, {"repo-layout-cloud.tar.gz", "*backend.CloudLayout"}, - {"repo-layout-s3-old.tar.gz", "*backend.S3Layout"}, + {"repo-layout-s3-old.tar.gz", "*backend.S3LegacyLayout"}, } var fs = &LocalFilesystem{} @@ -343,7 +343,7 @@ func TestParseLayout(t *testing.T) { }{ {"default", "", "*backend.DefaultLayout"}, {"cloud", "", "*backend.CloudLayout"}, - {"s3", "", "*backend.S3Layout"}, + {"s3legacy", "", "*backend.S3LegacyLayout"}, {"", "", "*backend.CloudLayout"}, } diff --git a/src/restic/backend/s3/s3.go b/src/restic/backend/s3/s3.go index 9afd13df5..241bfe323 100644 --- a/src/restic/backend/s3/s3.go +++ b/src/restic/backend/s3/s3.go @@ -45,7 +45,7 @@ func Open(cfg Config) (restic.Backend, error) { bucketname: cfg.Bucket, prefix: cfg.Prefix, cacheObjSize: make(map[string]int64), - Layout: &backend.S3Layout{Path: cfg.Prefix, Join: path.Join}, + Layout: &backend.S3LegacyLayout{Path: cfg.Prefix, Join: path.Join}, } client.SetCustomTransport(backend.Transport())