sync: handle new sync format: flags

This commit is contained in:
Thibaut 2018-05-12 02:01:49 +02:00 committed by Pierre-Olivier Mercier
commit 3b7d9a2a75
4 changed files with 35 additions and 117 deletions

View file

@ -5,7 +5,6 @@ import (
"fmt"
"log"
"os"
"path"
"time"
"sync"
@ -34,19 +33,7 @@ func SyncDeep(i Importer) (errs map[string][]string) {
for _, exercice := range exercices {
errs[theme.Name] = append(errs[theme.Name], SyncExerciceFiles(i, exercice)...)
errs[theme.Name] = append(errs[theme.Name], SyncExerciceHints(i, exercice)...)
hasFlags := false
if i.exists(path.Join(exercice.Path, "flags.txt")) {
errs[theme.Name] = append(errs[theme.Name], SyncExerciceKeys(i, exercice)...)
hasFlags = true
}
if i.exists(path.Join(exercice.Path, "flags-mcq.txt")) || i.exists(path.Join(exercice.Path, "flags-ucq.txt")) {
errs[theme.Name] = append(errs[theme.Name], SyncExerciceMCQ(i, exercice)...)
hasFlags = true
}
if !hasFlags {
errs[theme.Name] = append(errs[theme.Name], fmt.Sprintf("%q: has no flags!", path.Base(exercice.Path)))
}
errs[theme.Name] = append(errs[theme.Name], SyncExerciceKeys(i, exercice)...)
}
}
}