2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-26 20:30:19 +00:00

Create subdirs below data/

This commit is contained in:
Alexander Neumann 2017-07-02 15:29:54 +02:00
parent e7577d7bb4
commit 03f66b8d74
3 changed files with 16 additions and 2 deletions

Binary file not shown.

View File

@ -1,6 +1,9 @@
package backend
import "restic"
import (
"encoding/hex"
"restic"
)
// DefaultLayout implements the default layout for local and sftp backends, as
// described in the Design document. The `data` directory has one level of
@ -49,11 +52,18 @@ func (l *DefaultLayout) Filename(h restic.Handle) string {
return l.Join(l.Dirname(h), name)
}
// Paths returns all directory names
// Paths returns all directory names needed for a repo.
func (l *DefaultLayout) Paths() (dirs []string) {
for _, p := range defaultLayoutPaths {
dirs = append(dirs, l.Join(l.Path, p))
}
// 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))
}
return dirs
}

View File

@ -111,6 +111,10 @@ func TestDefaultLayout(t *testing.T) {
filepath.Join(tempdir, "keys"),
}
for i := 0; i < 256; i++ {
want = append(want, filepath.Join(tempdir, "data", fmt.Sprintf("%02x", i)))
}
sort.Sort(sort.StringSlice(want))
sort.Sort(sort.StringSlice(dirs))