mirror of
https://github.com/restic/restic.git
synced 2024-12-23 08:16:36 +00:00
index: misc cleanups
This commit is contained in:
parent
68fa0e0305
commit
72482ce5bd
2 changed files with 9 additions and 6 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
// ForAllIndexes loads all index files in parallel and calls the given callback.
|
||||
// It is guaranteed that the function is not run concurrently. If the callback
|
||||
// returns an error, this function is cancelled and also returns that error.
|
||||
func ForAllIndexes(ctx context.Context, lister restic.Lister, repo restic.ListerLoaderUnpacked,
|
||||
func ForAllIndexes(ctx context.Context, lister restic.Lister, repo restic.LoaderUnpacked,
|
||||
fn func(id restic.ID, index *Index, oldFormat bool, err error) error) error {
|
||||
|
||||
// decoding an index can take quite some time such that this can be both CPU- or IO-bound
|
||||
|
|
|
@ -23,12 +23,15 @@ type MasterIndex struct {
|
|||
|
||||
// NewMasterIndex creates a new master index.
|
||||
func NewMasterIndex() *MasterIndex {
|
||||
mi := &MasterIndex{pendingBlobs: restic.NewBlobSet()}
|
||||
mi.clear()
|
||||
return mi
|
||||
}
|
||||
|
||||
func (mi *MasterIndex) clear() {
|
||||
// Always add an empty final index, such that MergeFinalIndexes can merge into this.
|
||||
// Note that removing this index could lead to a race condition in the rare
|
||||
// situation that only two indexes exist which are saved and merged concurrently.
|
||||
idx := []*Index{NewIndex()}
|
||||
idx[0].Finalize()
|
||||
return &MasterIndex{idx: idx, pendingBlobs: restic.NewBlobSet()}
|
||||
mi.idx = []*Index{NewIndex()}
|
||||
mi.idx[0].Finalize()
|
||||
}
|
||||
|
||||
func (mi *MasterIndex) MarkCompressed() {
|
||||
|
|
Loading…
Reference in a new issue