admin/sync: avoid false positive when no files are distributed

This commit is contained in:
nemunaire 2018-01-06 16:50:47 +01:00
parent fc902e1063
commit 809d166a2d

View file

@ -10,8 +10,11 @@ import (
"srs.epita.fr/fic-server/libfic" "srs.epita.fr/fic-server/libfic"
) )
func SyncExerciceFiles(i Importer, exercice fic.Exercice) []string { func SyncExerciceFiles(i Importer, exercice fic.Exercice) (errs []string) {
var errs []string // If no files directory, don't display error
if ! i.exists(path.Join(exercice.Path, "files")) {
return
}
if digs, err := getFileContent(i, path.Join(exercice.Path, "files", "DIGESTS.txt")); err != nil { if digs, err := getFileContent(i, path.Join(exercice.Path, "files", "DIGESTS.txt")); err != nil {
errs = append(errs, fmt.Sprintf("%q: unable to read DIGESTS.txt: %s", path.Base(exercice.Path), err)) errs = append(errs, fmt.Sprintf("%q: unable to read DIGESTS.txt: %s", path.Base(exercice.Path), err))
@ -75,5 +78,5 @@ func SyncExerciceFiles(i Importer, exercice fic.Exercice) []string {
} }
} }
} }
return errs return
} }