mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 06:07:44 +00:00
Reduce dir depth for trees and data by one
This commit is contained in:
parent
bd4a5ca687
commit
4b6c7f1584
@ -167,14 +167,14 @@ func (b *Local) dirname(t Type, id ID) string {
|
|||||||
case Data:
|
case Data:
|
||||||
n = dataPath
|
n = dataPath
|
||||||
if id != nil {
|
if id != nil {
|
||||||
n = filepath.Join(dataPath, fmt.Sprintf("%02x", id[0]), fmt.Sprintf("%02x", id[1]))
|
n = filepath.Join(dataPath, fmt.Sprintf("%02x", id[0]))
|
||||||
}
|
}
|
||||||
case Snapshot:
|
case Snapshot:
|
||||||
n = snapshotPath
|
n = snapshotPath
|
||||||
case Tree:
|
case Tree:
|
||||||
n = treePath
|
n = treePath
|
||||||
if id != nil {
|
if id != nil {
|
||||||
n = filepath.Join(treePath, fmt.Sprintf("%02x", id[0]), fmt.Sprintf("%02x", id[1]))
|
n = filepath.Join(treePath, fmt.Sprintf("%02x", id[0]))
|
||||||
}
|
}
|
||||||
case Map:
|
case Map:
|
||||||
n = mapPath
|
n = mapPath
|
||||||
@ -289,7 +289,7 @@ func (b *Local) List(t Type) (IDs, error) {
|
|||||||
// TODO: use os.Open() and d.Readdirnames() instead of Glob()
|
// TODO: use os.Open() and d.Readdirnames() instead of Glob()
|
||||||
var pattern string
|
var pattern string
|
||||||
if t == Data || t == Tree {
|
if t == Data || t == Tree {
|
||||||
pattern = filepath.Join(b.dirname(t, nil), "*", "*", "*")
|
pattern = filepath.Join(b.dirname(t, nil), "*", "*")
|
||||||
} else {
|
} else {
|
||||||
pattern = filepath.Join(b.dirname(t, nil), "*")
|
pattern = filepath.Join(b.dirname(t, nil), "*")
|
||||||
}
|
}
|
||||||
|
@ -275,14 +275,14 @@ func (r *SFTP) dirname(t Type, id ID) string {
|
|||||||
case Data:
|
case Data:
|
||||||
n = dataPath
|
n = dataPath
|
||||||
if id != nil {
|
if id != nil {
|
||||||
n = filepath.Join(dataPath, fmt.Sprintf("%02x", id[0]), fmt.Sprintf("%02x", id[1]))
|
n = filepath.Join(dataPath, fmt.Sprintf("%02x", id[0]))
|
||||||
}
|
}
|
||||||
case Snapshot:
|
case Snapshot:
|
||||||
n = snapshotPath
|
n = snapshotPath
|
||||||
case Tree:
|
case Tree:
|
||||||
n = treePath
|
n = treePath
|
||||||
if id != nil {
|
if id != nil {
|
||||||
n = filepath.Join(treePath, fmt.Sprintf("%02x", id[0]), fmt.Sprintf("%02x", id[1]))
|
n = filepath.Join(treePath, fmt.Sprintf("%02x", id[0]))
|
||||||
}
|
}
|
||||||
case Map:
|
case Map:
|
||||||
n = mapPath
|
n = mapPath
|
||||||
@ -408,16 +408,9 @@ func (r *SFTP) List(t Type) (IDs, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dir1 := range list1 {
|
|
||||||
// read second level
|
|
||||||
list2, err := r.c.ReadDir(filepath.Join(basedir, dir1.Name()))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// read files
|
// read files
|
||||||
for _, dir2 := range list2 {
|
for _, dir := range list1 {
|
||||||
entries, err := r.c.ReadDir(filepath.Join(basedir, dir1.Name(), dir2.Name()))
|
entries, err := r.c.ReadDir(filepath.Join(basedir, dir.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -426,7 +419,6 @@ func (r *SFTP) List(t Type) (IDs, error) {
|
|||||||
list = append(list, entry)
|
list = append(list, entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
list, err = r.c.ReadDir(r.dirname(t, nil))
|
list, err = r.c.ReadDir(r.dirname(t, nil))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user