From 66391baeefc196326169f93b150b11f8b9159ecd Mon Sep 17 00:00:00 2001 From: nemunaire Date: Sun, 24 Jun 2018 18:53:10 +0200 Subject: [PATCH] sync: alert when imported file is empty --- admin/sync/exercice_files.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/sync/exercice_files.go b/admin/sync/exercice_files.go index ee676993..ee6de6cd 100644 --- a/admin/sync/exercice_files.go +++ b/admin/sync/exercice_files.go @@ -71,12 +71,14 @@ func SyncExerciceFiles(i Importer, exercice fic.Exercice) (errs []string) { continue } - if _, err := i.importFile(path.Join(exercice.Path, "files", fname), + if f, err := i.importFile(path.Join(exercice.Path, "files", fname), func(filePath string, origin string) (interface{}, error) { return exercice.ImportFile(filePath, origin, digests[fname]) }); err != nil { errs = append(errs, fmt.Sprintf("%q: unable to import file %q: %s", path.Base(exercice.Path), fname, err)) continue + } else if f.(fic.EFile).Size == 0 { + errs = append(errs, fmt.Sprintf("%q: WARNING imported file %q is empty!", path.Base(exercice.Path), fname)) } } }