From 8b261011b6fb84c7df50e06deb57c6de994b43c5 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 14 May 2021 01:14:30 +0200 Subject: [PATCH] repochecker: new option avoiding failure if resolution.mp4 missing --- admin/sync/exercices.go | 10 +++++++++- repochecker/main.go | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/admin/sync/exercices.go b/admin/sync/exercices.go index e6261ae3..55686757 100644 --- a/admin/sync/exercices.go +++ b/admin/sync/exercices.go @@ -2,6 +2,7 @@ package sync import ( "fmt" + "log" "path" "strconv" "strings" @@ -13,6 +14,9 @@ import ( "srs.epita.fr/fic-server/libfic" ) +// LogMissingResolution logs the absence of resolution.mp4 instead of returning an error. +var LogMissingResolution = false + func fixnbsp(s string) string { return strings.Replace(strings.Replace(strings.Replace(s, " ?", " ?", -1), " !", " !", -1), " :", " :", -1) } @@ -189,7 +193,11 @@ func BuildExercice(i Importer, theme fic.Theme, epath string, dmap *map[int64]fi // Handle video e.VideoURI = path.Join(epath, "resolution.mp4") if !i.exists(e.VideoURI) { - errs = append(errs, fmt.Sprintf("%q: resolution.mp4: no video file found at %s", edir, e.VideoURI)) + if LogMissingResolution { + log.Printf("%q: resolution.mp4: no video file found at %s", edir, e.VideoURI) + } else { + 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)) diff --git a/repochecker/main.go b/repochecker/main.go index 81a8a38b..1964690a 100644 --- a/repochecker/main.go +++ b/repochecker/main.go @@ -76,6 +76,7 @@ func main() { flag.BoolVar(&fic.OptionalDigest, "optionaldigest", fic.OptionalDigest, "Is the digest required when importing files?") flag.BoolVar(&fic.StrongDigest, "strongdigest", fic.StrongDigest, "Are BLAKE2b digests required or is SHA-1 good enough?") flag.BoolVar(&skipFileChecks, "skipfiledigests", skipFileChecks, "Don't perform DIGESTS checks on file to speed up the checks") + flag.BoolVar(&sync.LogMissingResolution, "skipresolution", sync.LogMissingResolution, "Don't fail if resolution.mp4 is absent") flag.Parse() log.SetPrefix("[repochecker] ")