sync: Replace []error by go.uber.org/multierr
This commit is contained in:
parent
9f49a689fd
commit
b6966d47ce
25 changed files with 380 additions and 348 deletions
|
|
@ -7,11 +7,13 @@ import (
|
|||
"log"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/multierr"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
func checkZip(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
func checkZip(file *fic.EFile, exceptions *sync.CheckExceptions) (errs error) {
|
||||
fd, closer, err := sync.GetFile(sync.GlobalImporter, file.GetOrigin())
|
||||
if err != nil {
|
||||
log.Printf("Unable to open %q: %s", file.GetOrigin(), err.Error())
|
||||
|
|
@ -39,11 +41,11 @@ func checkZip(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error)
|
|||
|
||||
if len(r.File) < 2 {
|
||||
if !exceptions.HasException(":one-file-tarball") {
|
||||
errs = append(errs, fmt.Errorf("don't make a ZIP archive for one file, use gzip instead"))
|
||||
errs = multierr.Append(errs, fmt.Errorf("don't make a ZIP archive for one file, use gzip instead"))
|
||||
}
|
||||
} else if len(r.File) < 5 && false {
|
||||
if !exceptions.HasException(":few-files-tarball") {
|
||||
errs = append(errs, fmt.Errorf("don't make a ZIP archive for so little files (:few-files-tarball)"))
|
||||
errs = multierr.Append(errs, fmt.Errorf("don't make a ZIP archive for so little files (:few-files-tarball)"))
|
||||
}
|
||||
} else {
|
||||
log.Printf("%d files found in %q", len(r.File), file.Name)
|
||||
|
|
@ -83,7 +85,7 @@ func checkZip(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error)
|
|||
}
|
||||
|
||||
if nbLinuxDirFound > 2 && !exceptions.HasException(":not-a-linux-rootfs") {
|
||||
errs = append(errs, fmt.Errorf("don't use a ZIP archive to store an Unix file system, prefer a tarball (:not-a-linux-rootfs)"))
|
||||
errs = multierr.Append(errs, fmt.Errorf("don't use a ZIP archive to store an Unix file system, prefer a tarball (:not-a-linux-rootfs)"))
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
|||
Reference in a new issue