sync: add dependency on flag to download file

This commit is contained in:
nemunaire 2018-09-07 20:53:08 +02:00 committed by Pierre-Olivier Mercier
parent dcfb34c6fd
commit 1e2a74f3ca
9 changed files with 112 additions and 16 deletions

View file

@ -40,9 +40,20 @@ func SyncExerciceKeys(i Importer, exercice fic.Exercice) (errs []string) {
errs = append(errs, fmt.Sprintf("%q: WARNING flag #%d: non-printable characters in flag, is this really expected?", path.Base(exercice.Path), nline + 1))
}
if _, err := exercice.AddRawKey(flag.Label, flag.Raw); err != nil {
if k, err := exercice.AddRawKey(flag.Label, flag.Raw); err != nil {
errs = append(errs, fmt.Sprintf("%q: error flag #%d: %s", path.Base(exercice.Path), nline + 1, err))
continue
} else {
// Import dependency to file
for _, lf := range flag.LockedFile {
if rf, err := exercice.GetFileByFilename(lf.Filename); err != nil {
errs = append(errs, fmt.Sprintf("%q: error flag #%d dependency to %s: %s", path.Base(exercice.Path), nline + 1, lf.Filename, err))
continue
} else if err := rf.AddDepend(k); err != nil {
errs = append(errs, fmt.Sprintf("%q: error flag #%d dependency to %s: %s", path.Base(exercice.Path), nline + 1, lf.Filename, err))
continue
}
}
}
}
@ -56,9 +67,20 @@ func SyncExerciceKeys(i Importer, exercice fic.Exercice) (errs []string) {
errs = append(errs, fmt.Sprintf("%q: WARNING flag UCQ #%d: non-printable characters in flag, is this really expected?", path.Base(exercice.Path), nline + 1))
}
if _, err := exercice.AddRawKey(flag.Label, flag.Raw); err != nil {
if k, err := exercice.AddRawKey(flag.Label, flag.Raw); err != nil {
errs = append(errs, fmt.Sprintf("%q: error flag UCQ #%d: %s", path.Base(exercice.Path), nline + 1, err))
continue
} else {
// Import dependency to file
for _, lf := range flag.LockedFile {
if rf, err := exercice.GetFileByFilename(lf.Filename); err != nil {
errs = append(errs, fmt.Sprintf("%q: error flag UCQ #%d dependency to %s: %s", path.Base(exercice.Path), nline + 1, lf.Filename, err))
continue
} else if err := rf.AddDepend(k); err != nil {
errs = append(errs, fmt.Sprintf("%q: error flag UCQ #%d dependency to %s: %s", path.Base(exercice.Path), nline + 1, lf.Filename, err))
continue
}
}
}
}