2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-02 11:46:36 +00:00

layout: Add String() and Name()

This commit is contained in:
Alexander Neumann 2017-06-07 21:59:41 +02:00
parent b8b5c8e8c9
commit 7cf8f59987
4 changed files with 28 additions and 0 deletions

View File

@ -17,6 +17,7 @@ type Layout interface {
Dirname(restic.Handle) string
Basedir(restic.FileType) string
Paths() []string
Name() string
}
// Filesystem is the abstraction of a file system used for a backend.

View File

@ -19,6 +19,15 @@ var defaultLayoutPaths = map[restic.FileType]string{
restic.KeyFile: "keys",
}
func (l *DefaultLayout) String() string {
return "<DefaultLayout>"
}
// Name returns the name for this layout.
func (l *DefaultLayout) Name() string {
return "default"
}
// Dirname returns the directory path for a given file type and name.
func (l *DefaultLayout) Dirname(h restic.Handle) string {
p := defaultLayoutPaths[h.Type]

View File

@ -11,6 +11,15 @@ type RESTLayout struct {
var restLayoutPaths = defaultLayoutPaths
func (l *RESTLayout) String() string {
return "<RESTLayout>"
}
// Name returns the name for this layout.
func (l *RESTLayout) Name() string {
return "rest"
}
// Dirname returns the directory path for a given file type and name.
func (l *RESTLayout) Dirname(h restic.Handle) string {
if h.Type == restic.ConfigFile {

View File

@ -18,6 +18,15 @@ var s3LayoutPaths = map[restic.FileType]string{
restic.KeyFile: "key",
}
func (l *S3LegacyLayout) String() string {
return "<S3LegacyLayout>"
}
// Name returns the name for this layout.
func (l *S3LegacyLayout) Name() string {
return "s3legacy"
}
// join calls Join with the first empty elements removed.
func (l *S3LegacyLayout) join(url string, items ...string) string {
for len(items) > 0 && items[0] == "" {