mirror of https://github.com/restic/restic.git
repository: replace HasBlob with LookupBlobSize
This commit is contained in:
parent
8f1e70cd9b
commit
0aa5c53842
|
@ -167,8 +167,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range []restic.BlobType{restic.DataBlob, restic.TreeBlob} {
|
for _, t := range []restic.BlobType{restic.DataBlob, restic.TreeBlob} {
|
||||||
bh := restic.BlobHandle{ID: id, Type: t}
|
if _, ok := repo.LookupBlobSize(id, t); !ok {
|
||||||
if !repo.HasBlob(bh) {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Rep
|
||||||
|
|
||||||
// Do we already have this tree blob?
|
// Do we already have this tree blob?
|
||||||
treeHandle := restic.BlobHandle{ID: tree.ID, Type: restic.TreeBlob}
|
treeHandle := restic.BlobHandle{ID: tree.ID, Type: restic.TreeBlob}
|
||||||
if !dstRepo.HasBlob(treeHandle) {
|
if _, ok := dstRepo.LookupBlobSize(treeHandle.ID, treeHandle.Type); !ok {
|
||||||
// copy raw tree bytes to avoid problems if the serialization changes
|
// copy raw tree bytes to avoid problems if the serialization changes
|
||||||
enqueue(treeHandle)
|
enqueue(treeHandle)
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Rep
|
||||||
// Copy the blobs for this file.
|
// Copy the blobs for this file.
|
||||||
for _, blobID := range entry.Content {
|
for _, blobID := range entry.Content {
|
||||||
h := restic.BlobHandle{Type: restic.DataBlob, ID: blobID}
|
h := restic.BlobHandle{Type: restic.DataBlob, ID: blobID}
|
||||||
if !dstRepo.HasBlob(h) {
|
if _, ok := dstRepo.LookupBlobSize(h.ID, h.Type); !ok {
|
||||||
enqueue(h)
|
enqueue(h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,7 @@ func (arch *Archiver) loadSubtree(ctx context.Context, node *restic.Node) (*rest
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arch *Archiver) wrapLoadTreeError(id restic.ID, err error) error {
|
func (arch *Archiver) wrapLoadTreeError(id restic.ID, err error) error {
|
||||||
if arch.Repo.HasBlob(restic.BlobHandle{ID: id, Type: restic.TreeBlob}) {
|
if _, ok := arch.Repo.LookupBlobSize(id, restic.TreeBlob); ok {
|
||||||
err = errors.Errorf("tree %v could not be loaded; the repository could be damaged: %v", id, err)
|
err = errors.Errorf("tree %v could not be loaded; the repository could be damaged: %v", id, err)
|
||||||
} else {
|
} else {
|
||||||
err = errors.Errorf("tree %v is not known; the repository could be damaged, run `repair index` to try to repair it", id)
|
err = errors.Errorf("tree %v is not known; the repository could be damaged, run `repair index` to try to repair it", id)
|
||||||
|
@ -390,7 +390,7 @@ func (fn *FutureNode) take(ctx context.Context) futureNodeResult {
|
||||||
func (arch *Archiver) allBlobsPresent(previous *restic.Node) bool {
|
func (arch *Archiver) allBlobsPresent(previous *restic.Node) bool {
|
||||||
// check if all blobs are contained in index
|
// check if all blobs are contained in index
|
||||||
for _, id := range previous.Content {
|
for _, id := range previous.Content {
|
||||||
if !arch.Repo.HasBlob(restic.BlobHandle{ID: id, Type: restic.DataBlob}) {
|
if _, ok := arch.Repo.LookupBlobSize(id, restic.DataBlob); !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -578,10 +578,6 @@ func (r *Repository) Connections() uint {
|
||||||
return r.be.Connections()
|
return r.be.Connections()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) HasBlob(bh restic.BlobHandle) bool {
|
|
||||||
return r.idx.Has(bh)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Repository) LookupBlob(bh restic.BlobHandle) []restic.PackedBlob {
|
func (r *Repository) LookupBlob(bh restic.BlobHandle) []restic.PackedBlob {
|
||||||
return r.idx.Lookup(bh)
|
return r.idx.Lookup(bh)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ type Repository interface {
|
||||||
SetIndex(MasterIndex) error
|
SetIndex(MasterIndex) error
|
||||||
SaveIndex(ctx context.Context, excludePacks IDSet, extraObsolete IDs, opts MasterIndexSaveOpts) error
|
SaveIndex(ctx context.Context, excludePacks IDSet, extraObsolete IDs, opts MasterIndexSaveOpts) error
|
||||||
|
|
||||||
HasBlob(BlobHandle) bool
|
|
||||||
LookupBlob(BlobHandle) []PackedBlob
|
LookupBlob(BlobHandle) []PackedBlob
|
||||||
LookupBlobSize(ID, BlobType) (uint, bool)
|
LookupBlobSize(ID, BlobType) (uint, bool)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue