mirror of
https://github.com/restic/restic.git
synced 2026-10-11 20:47:12 +00:00
Fix O(n) backend list calls in FindFilteredSnapshots
When resolving snapshotIDs in FindFilteredSnapshots either FindLatestSnapshot or FindSnapshot is called. Both operations issue a list operation to the backend. When for example passing a long list of snapshot ids to `forget` this could lead to a large number of list operations.
This commit is contained in:
1 parent
3d29083e60
commit
9e12159230
2 files changed
+12
-1
No files matched your search
@@ -81,6 +81,10 @@ func (m *memorizedLister) List(ctx context.Context, t restic.FileType, fn func(r
|
||||
}
|
||||
|
||||
func MemorizeList(ctx context.Context, be restic.Lister, t restic.FileType) (restic.Lister, error) {
|
||||
if _, ok := be.(*memorizedLister); ok {
|
||||
return be, nil
|
||||
}
|
||||
|
||||
var fileInfos []restic.FileInfo
|
||||
err := be.List(ctx, t, func(fi restic.FileInfo) error {
|
||||
fileInfos = append(fileInfos, fi)
|
||||
|
||||
Reference in new issue
Block a user