2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 06:46:34 +00:00

Rename layout s3 -> s3legacy

This commit is contained in:
Alexander Neumann 2017-05-15 21:58:03 +02:00
parent a4e3a0dd97
commit 61cade6222
4 changed files with 22 additions and 22 deletions

View File

@ -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

View File

@ -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])
}

View File

@ -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"},
}

View File

@ -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())