fix(GODT-2963): Use multi error to report file removal errors

Do not abort removing files on first error. Collect errors and try to
remove as many as possible. This would cause some state files to not be
removed on windows.
This commit is contained in:
Leander Beernaert 2023-09-27 11:30:46 +02:00
parent f4958b9b53
commit 07c03c6920
1 changed files with 3 additions and 2 deletions

View File

@ -72,11 +72,12 @@ func remove(dir string, except ...string) error {
sort.Sort(sort.Reverse(sort.StringSlice(toRemove)))
var multiErr error
for _, target := range toRemove {
if err := os.RemoveAll(target); err != nil {
return err
multiErr = multierror.Append(multiErr, err)
}
}
return nil
return multiErr
}