From d89cd2f0ca345bb2ddd6352d3e459053841ef5c6 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sat, 8 Dec 2018 00:53:13 +0100 Subject: [PATCH] sync: Allow \r at EOL in DIGESTS --- admin/sync/exercice_files.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/sync/exercice_files.go b/admin/sync/exercice_files.go index ee6de6cd..a9689110 100644 --- a/admin/sync/exercice_files.go +++ b/admin/sync/exercice_files.go @@ -28,14 +28,14 @@ func SyncExerciceFiles(i Importer, exercice fic.Exercice) (errs []string) { // Parse DIGESTS.txt digests := map[string][]byte{} for nline, d := range strings.Split(digs, "\n") { - if dsplt := strings.SplitN(d, " ", 2); len(dsplt) != 2 { + if dsplt := strings.SplitN(d, " ", 2); len(dsplt) < 2 { errs = append(errs, fmt.Sprintf("%q: unable to parse DIGESTS.txt line %d: invalid format", path.Base(exercice.Path), nline + 1)) continue } else if hash, err := hex.DecodeString(dsplt[0]); err != nil { errs = append(errs, fmt.Sprintf("%q: unable to parse DIGESTS.txt line %d: %s", path.Base(exercice.Path), nline + 1, err)) continue } else { - digests[strings.TrimLeftFunc(dsplt[1], unicode.IsSpace)] = hash + digests[strings.TrimFunc(dsplt[1], unicode.IsSpace)] = hash } }