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:
parent
e7577d7bb4
commit
03f66b8d74
BIN
src/cmds/restic/testdata/small-repo.tar.gz
vendored
BIN
src/cmds/restic/testdata/small-repo.tar.gz
vendored
Binary file not shown.
@ -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
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user