Skip to content

Commit 670a1fb

Browse files
committed
backend: allow multiple storage areas
In a future commit, we'll learn how to read alternate repositories, so teach the backend code how to deal with multiple loose and packed storage objects.
1 parent bda7989 commit 670a1fb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

backend.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ func NewFilesystemBackend(root, tmp string) (storage.Backend, error) {
1515
return nil, err
1616
}
1717

18-
return &filesystemBackend{fs: fsobj, packs: packs}, nil
18+
return &filesystemBackend{
19+
fs: fsobj,
20+
backends: []storage.Storage{fsobj, packs},
21+
}, nil
1922
}
2023

2124
// NewMemoryBackend initializes a new memory-based backend.
@@ -27,12 +30,12 @@ func NewMemoryBackend(m map[string]io.ReadWriter) (storage.Backend, error) {
2730
}
2831

2932
type filesystemBackend struct {
30-
fs *fileStorer
31-
packs *pack.Storage
33+
fs *fileStorer
34+
backends []storage.Storage
3235
}
3336

3437
func (b *filesystemBackend) Storage() (storage.Storage, storage.WritableStorage) {
35-
return storage.MultiStorage(b.fs, b.packs), b.fs
38+
return storage.MultiStorage(b.backends...), b.fs
3639
}
3740

3841
type memoryBackend struct {

0 commit comments

Comments
 (0)