From e77002f84112b28ec89d89d899a68a4e062667c0 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 1 May 2023 12:02:50 +0200 Subject: [PATCH] restore: correctly count hardlinks in progress bar For hardlinked files, only the first instance of that file increases the amount of bytes to restore. All later instances only increase the file count but not the restore size. --- internal/restorer/restorer.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/restorer/restorer.go b/internal/restorer/restorer.go index 289883ed0..88eeee658 100644 --- a/internal/restorer/restorer.go +++ b/internal/restorer/restorer.go @@ -257,21 +257,28 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error { return nil } - if res.progress != nil { - res.progress.AddFile(node.Size) - } - if node.Size == 0 { + if res.progress != nil { + res.progress.AddFile(node.Size) + } return nil // deal with empty files later } if node.Links > 1 { if idx.Has(node.Inode, node.DeviceID) { + if res.progress != nil { + // a hardlinked file does not increase the restore size + res.progress.AddFile(0) + } return nil } idx.Add(node.Inode, node.DeviceID, location) } + if res.progress != nil { + res.progress.AddFile(node.Size) + } + filerestorer.addFile(location, node.Content, int64(node.Size)) return nil