sync: Allow \r at EOL in DIGESTS

This commit is contained in:
nemunaire 2018-12-08 00:53:13 +01:00
parent 910ec94fd8
commit d89cd2f0ca

View File

@ -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
}
}