mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
copy: Update for modernized repository interface
This commit is contained in:
parent
4508d406ef
commit
908b23fda0
@ -168,27 +168,15 @@ func copyTree(ctx context.Context, srcRepo, dstRepo restic.Repository, treeID re
|
||||
continue
|
||||
}
|
||||
debug.Log("Copying blob %s\n", blobID.Str())
|
||||
size, found := srcRepo.LookupBlobSize(blobID, restic.DataBlob)
|
||||
if !found {
|
||||
return fmt.Errorf("LookupBlobSize(%v) failed", blobID)
|
||||
}
|
||||
buf := restic.NewBlobBuffer(int(size))
|
||||
n, err := srcRepo.LoadBlob(ctx, restic.DataBlob, blobID, buf)
|
||||
buf, err := srcRepo.LoadBlob(ctx, restic.DataBlob, blobID, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("LoadBlob(%v) returned error %v", blobID, err)
|
||||
}
|
||||
if n != len(buf) {
|
||||
return fmt.Errorf("wrong number of bytes read, want %d, got %d", len(buf), n)
|
||||
}
|
||||
|
||||
newBlobID, err := dstRepo.SaveBlob(ctx, restic.DataBlob, buf, blobID)
|
||||
_, _, err = dstRepo.SaveBlob(ctx, restic.DataBlob, buf, blobID, false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("SaveBlob(%v) returned error %v", blobID, err)
|
||||
}
|
||||
// Assurance only.
|
||||
if newBlobID != blobID {
|
||||
return fmt.Errorf("SaveBlob(%v) returned unexpected id %s", blobID.Str(), newBlobID.Str())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user