fix: track and report file restore failures #22
@ -118,6 +118,8 @@ func (v *Vaultik) Restore(opts *RestoreOptions) error {
|
|||||||
|
|
||||||
if err := v.restoreFile(v.ctx, repos, file, opts.TargetDir, identity, chunkToBlobMap, blobCache, result); err != nil {
|
if err := v.restoreFile(v.ctx, repos, file, opts.TargetDir, identity, chunkToBlobMap, blobCache, result); err != nil {
|
||||||
log.Error("Failed to restore file", "path", file.Path, "error", err)
|
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
|
// Continue with other files
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -147,6 +149,13 @@ func (v *Vaultik) Restore(opts *RestoreOptions) error {
|
|||||||
result.Duration.Round(time.Second),
|
result.Duration.Round(time.Second),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if result.FilesFailed > 0 {
|
||||||
|
_, _ = fmt.Fprintf(v.Stdout, "\nWARNING: %d file(s) failed to restore:\n", result.FilesFailed)
|
||||||
|
for _, path := range result.FailedFiles {
|
||||||
|
_, _ = fmt.Fprintf(v.Stdout, " - %s\n", path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Run verification if requested
|
// Run verification if requested
|
||||||
if opts.Verify {
|
if opts.Verify {
|
||||||
if err := v.verifyRestoredFiles(v.ctx, repos, files, opts.TargetDir, result); err != nil {
|
if err := v.verifyRestoredFiles(v.ctx, repos, files, opts.TargetDir, result); err != nil {
|
||||||
@ -167,6 +176,10 @@ func (v *Vaultik) Restore(opts *RestoreOptions) error {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if result.FilesFailed > 0 {
|
||||||
|
return fmt.Errorf("%d file(s) failed to restore", result.FilesFailed)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user