sync: check video file size during import process

This commit is contained in:
nemunaire 2019-01-19 01:13:17 +01:00
commit 6042f9b477
2 changed files with 45 additions and 0 deletions

View file

@ -178,6 +178,12 @@ func SyncExercice(i Importer, theme fic.Theme, epath string, dmap *map[int64]fic
if !i.exists(e.VideoURI) {
errs = append(errs, fmt.Sprintf("%q: resolution.mp4: no video file found at %s", edir, e.VideoURI))
e.VideoURI = ""
} else if size, err := getFileSize(i, e.VideoURI); err != nil {
errs = append(errs, fmt.Sprintf("%q: resolution.mp4: ", edir, err))
e.VideoURI = ""
} else if size == 0 {
errs = append(errs, fmt.Sprintf("%q: resolution.mp4: The file is empty!", edir))
e.VideoURI = ""
}
// Create or update the exercice