package sync import ( "fmt" "path" "srs.epita.fr/fic-server/libfic" ) func SyncExerciceHints(i Importer, exercice fic.Exercice) []string { var errs []string if _, err := exercice.WipeHints(); err != nil { errs = append(errs, err.Error()) } else if hints, err := i.listDir(path.Join(exercice.Path, "hints")); err != nil { errs = append(errs, err.Error()) } else { for _, hfile := range hints { if hint_cnt, err := getFileContent(i, path.Join(exercice.Path, "hints", hfile)); err != nil { errs = append(errs, fmt.Sprintf("%q: unable to read hint file %q: %s", path.Base(exercice.Path), hfile, err)) continue } else if _, err := exercice.AddHint(hfile, hint_cnt, 1); err != nil { errs = append(errs, fmt.Sprintf("%q: unable to add hint %q: %s", path.Base(exercice.Path), hfile, err)) continue } } } return errs }