mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
Loop over index files for 'list blobs'
=> reduces memory consumption a lot!
This commit is contained in:
parent
285b5236c2
commit
b5543cff5d
6
changelog/unreleased/pull-2786
Normal file
6
changelog/unreleased/pull-2786
Normal file
@ -0,0 +1,6 @@
|
||||
Enhancement: Optimize `list blobs` command
|
||||
|
||||
We've changed the implementation of `list blobs` which should be now a bit faster
|
||||
and consume almost no memory even for large repositories.
|
||||
|
||||
https://github.com/restic/restic/pull/2786
|
@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/index"
|
||||
"github.com/restic/restic/internal/repository"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@ -60,16 +60,16 @@ func runList(cmd *cobra.Command, opts GlobalOptions, args []string) error {
|
||||
case "locks":
|
||||
t = restic.LockFile
|
||||
case "blobs":
|
||||
idx, err := index.Load(opts.ctx, repo, nil)
|
||||
return repo.List(opts.ctx, restic.IndexFile, func(id restic.ID, size int64) error {
|
||||
idx, err := repository.LoadIndex(opts.ctx, repo, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, pack := range idx.Packs {
|
||||
for _, entry := range pack.Entries {
|
||||
Printf("%v %v\n", entry.Type, entry.ID)
|
||||
}
|
||||
for blobs := range idx.Each(opts.ctx) {
|
||||
Printf("%v %v\n", blobs.Type, blobs.ID)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return nil
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user