Compare commits
1 Commits
fix/issue-
...
036eaf9f97
| Author | SHA1 | Date | |
|---|---|---|---|
| 036eaf9f97 |
@@ -51,13 +51,7 @@ func CompressStream(dst io.Writer, src io.Reader, compressionLevel int, recipien
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, "", fmt.Errorf("creating writer: %w", err)
|
return 0, "", fmt.Errorf("creating writer: %w", err)
|
||||||
}
|
}
|
||||||
|
defer func() { _ = w.Close() }()
|
||||||
closed := false
|
|
||||||
defer func() {
|
|
||||||
if !closed {
|
|
||||||
_ = w.Close()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
if _, err := io.Copy(w, src); err != nil {
|
if _, err := io.Copy(w, src); err != nil {
|
||||||
@@ -68,7 +62,6 @@ func CompressStream(dst io.Writer, src io.Reader, compressionLevel int, recipien
|
|||||||
if err := w.Close(); err != nil {
|
if err := w.Close(); err != nil {
|
||||||
return 0, "", fmt.Errorf("closing writer: %w", err)
|
return 0, "", fmt.Errorf("closing writer: %w", err)
|
||||||
}
|
}
|
||||||
closed = true
|
|
||||||
|
|
||||||
return w.BytesWritten(), hex.EncodeToString(w.Sum256()), nil
|
return w.BytesWritten(), hex.EncodeToString(w.Sum256()), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user