mirror of
https://github.com/restic/restic.git
synced 2026-09-16 09:17:57 +00:00
layout: skip creation of pack subdirectories in integration tests
Each time a local backend is created, the local backend also creates all shard subdirectories. For the integration tests this has the downside that this results in ~120 (number of test) * 256 (number of directories) = 30k directories that are created unnecessarily. This significantly slows down test execution and cleanup.
This commit is contained in:
@@ -6,6 +6,10 @@ import (
|
||||
"github.com/restic/restic/internal/backend"
|
||||
)
|
||||
|
||||
// disablePackSubdirs is used to disable the creation of pack subdirectories.
|
||||
// Only used for testing.
|
||||
var disablePackSubdirs = false
|
||||
|
||||
// DefaultLayout implements the default layout for local and sftp backends, as
|
||||
// described in the Design document. The `data` directory has one level of
|
||||
// subdirs, two characters each (taken from the first two characters of the
|
||||
@@ -66,10 +70,12 @@ func (l *DefaultLayout) Paths() (dirs []string) {
|
||||
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[backend.PackFile], subdir))
|
||||
if !disablePackSubdirs {
|
||||
// also add subdirs
|
||||
for i := 0; i < 256; i++ {
|
||||
subdir := hex.EncodeToString([]byte{byte(i)})
|
||||
dirs = append(dirs, l.join(l.path, defaultLayoutPaths[backend.PackFile], subdir))
|
||||
}
|
||||
}
|
||||
|
||||
return dirs
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package layout
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDisablePackSubdirs(t testing.TB) {
|
||||
disablePackSubdirs = true
|
||||
}
|
||||
Reference in New Issue
Block a user