mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 12:52:27 -05:00
[bugfix] Rework MultiError to wrap + unwrap errors properly (#2057)
* rework multierror a bit * test multierror
This commit is contained in:
parent
2cee8f2dd8
commit
e8a20f587c
24 changed files with 263 additions and 154 deletions
|
|
@ -83,19 +83,23 @@ func (c *Cleaner) removeFiles(ctx context.Context, files ...string) (int, error)
|
|||
return len(files), nil
|
||||
}
|
||||
|
||||
var errs gtserror.MultiError
|
||||
var (
|
||||
errs gtserror.MultiError
|
||||
errCount int
|
||||
)
|
||||
|
||||
for _, path := range files {
|
||||
// Remove each provided storage path.
|
||||
log.Debugf(ctx, "removing file: %s", path)
|
||||
err := c.state.Storage.Delete(ctx, path)
|
||||
if err != nil && !errors.Is(err, storage.ErrNotFound) {
|
||||
errs.Appendf("error removing %s: %v", path, err)
|
||||
errs.Appendf("error removing %s: %w", path, err)
|
||||
errCount++
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate no. files removed.
|
||||
diff := len(files) - len(errs)
|
||||
diff := len(files) - errCount
|
||||
|
||||
// Wrap the combined error slice.
|
||||
if err := errs.Combine(); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue