mirror of
https://github.com/restic/restic.git
synced 2026-06-21 16:14:18 +00:00
c062a78dcd
This removes them from the public interface. The latter now only provides the PackBlob interface, without being bound to the type used internally by the pack package.
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
"iter"
|
|
|
|
"github.com/restic/restic/internal/errors"
|
|
"github.com/restic/restic/internal/repository/index"
|
|
"github.com/restic/restic/internal/restic"
|
|
)
|
|
|
|
// IndexBlob is one blob handle from an on-disk index file, or an error from loading/decoding
|
|
// that file.
|
|
type IndexBlob struct {
|
|
Handle restic.BlobHandle
|
|
Error error
|
|
}
|
|
|
|
// AllIndexBlobs streams blob handles from each index file without building a master index.
|
|
func AllIndexBlobs(ctx context.Context, lister restic.Lister, loader restic.LoaderUnpacked) iter.Seq[IndexBlob] {
|
|
return func(yield func(IndexBlob) bool) {
|
|
stopIteration := errors.New("stop index blob iteration")
|
|
err := index.ForAllIndexes(ctx, lister, loader, func(_ restic.ID, idx *index.Index, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for blob := range idx.Values() {
|
|
if ctx.Err() != nil {
|
|
return ctx.Err()
|
|
}
|
|
if !yield(IndexBlob{Handle: blob.Handle()}) {
|
|
return stopIteration
|
|
}
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil && !errors.Is(err, stopIteration) {
|
|
yield(IndexBlob{Error: err})
|
|
}
|
|
}
|
|
}
|