Compare commits

..

1 Commits

Author SHA1 Message Date
82a93c4be6 feat: add progress bar to restore operation
Add an interactive progress bar (using schollz/progressbar) to the
file restore loop, matching the existing pattern in verify. Shows
bytes restored with ETA when output is a terminal, falls back to
structured log progress every 100 files otherwise.

Fixes #20
2026-02-20 02:28:21 -08:00

View File

@ -127,13 +127,13 @@ func (v *Vaultik) Restore(opts *RestoreOptions) error {
bar = progressbar.NewOptions64(
totalBytesExpected,
progressbar.OptionSetDescription("Restoring"),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionSetWriter(v.Stderr),
progressbar.OptionShowBytes(true),
progressbar.OptionShowCount(),
progressbar.OptionSetWidth(40),
progressbar.OptionThrottle(100*time.Millisecond),
progressbar.OptionOnCompletion(func() {
fmt.Fprint(os.Stderr, "\n")
v.printfStderr("\n")
}),
progressbar.OptionSetRenderBlankState(true),
)
@ -148,7 +148,11 @@ func (v *Vaultik) Restore(opts *RestoreOptions) error {
log.Error("Failed to restore file", "path", file.Path, "error", err)
result.FilesFailed++
result.FailedFiles = append(result.FailedFiles, file.Path.String())
// Continue with other files
// Update progress bar even on failure
if bar != nil {
_ = bar.Add64(file.Size)
}
continue
}
// Update progress bar