sync: Replace []error by go.uber.org/multierr

This commit is contained in:
nemunaire 2023-11-22 12:16:53 +01:00
commit b6966d47ce
25 changed files with 380 additions and 348 deletions

View file

@ -4,17 +4,19 @@ import (
"path/filepath"
"strings"
"go.uber.org/multierr"
"srs.epita.fr/fic-server/admin/sync"
"srs.epita.fr/fic-server/libfic"
)
func InspectFile(file *fic.EFile, _ *fic.Exercice, exceptions *sync.CheckExceptions) (errs []error) {
func InspectFile(file *fic.EFile, _ *fic.Exercice, exceptions *sync.CheckExceptions) (errs error) {
if filepath.Ext(file.Name) == ".tar" || strings.HasSuffix(file.Name, ".tar.gz") || strings.HasSuffix(file.Name, ".tar.bz2") {
// Check there is more than 1 file in tarball
errs = append(errs, checkTarball(file, exceptions)...)
errs = multierr.Append(errs, checkTarball(file, exceptions))
} else if filepath.Ext(file.Name) == ".zip" {
// Check there is more than 1 file in zip
errs = append(errs, checkZip(file, exceptions)...)
errs = multierr.Append(errs, checkZip(file, exceptions))
}
return