mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 19:08:55 +00:00
restore --verify: buffer reuse consistency and comment
This commit is contained in:
parent
2b94742ca5
commit
bdcdfaf6b4
@ -363,7 +363,10 @@ func (res *Restorer) VerifyFiles(ctx context.Context, dst string) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the file target has the contents of node.
|
// Verify that the file target has the contents of node.
|
||||||
|
//
|
||||||
// buf and the first return value are scratch space, passed around for reuse.
|
// buf and the first return value are scratch space, passed around for reuse.
|
||||||
|
// Reusing buffers prevents the verifier goroutines allocating all of RAM and
|
||||||
|
// flushing the filesystem cache (at least on Linux).
|
||||||
func (res *Restorer) verifyFile(target string, node *restic.Node, buf []byte) ([]byte, error) {
|
func (res *Restorer) verifyFile(target string, node *restic.Node, buf []byte) ([]byte, error) {
|
||||||
f, err := os.Open(target)
|
f, err := os.Open(target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -374,7 +377,7 @@ func (res *Restorer) verifyFile(target string, node *restic.Node, buf []byte) ([
|
|||||||
fi, err := f.Stat()
|
fi, err := f.Stat()
|
||||||
switch {
|
switch {
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return nil, err
|
return buf, err
|
||||||
case int64(node.Size) != fi.Size():
|
case int64(node.Size) != fi.Size():
|
||||||
return buf, errors.Errorf("Invalid file size for %s: expected %d, got %d",
|
return buf, errors.Errorf("Invalid file size for %s: expected %d, got %d",
|
||||||
target, node.Size, fi.Size())
|
target, node.Size, fi.Size())
|
||||||
|
Loading…
Reference in New Issue
Block a user