Compare commits

...

2 Commits

Author SHA1 Message Date
ea8ad1d6db sync: Don't warn about no flag if WIP
All checks were successful
continuous-integration/drone/push Build is passing
2024-10-11 14:55:49 +02:00
e08dd2f2e8 sync: Allow empty files 2024-10-11 14:55:28 +02:00
3 changed files with 4 additions and 6 deletions

View File

@ -173,7 +173,9 @@ func getExerciceParams(i Importer, exercice *fic.Exercice) (params ExerciceParam
if params, _, err = parseExerciceParams(i, exercice.Path); err != nil { if params, _, err = parseExerciceParams(i, exercice.Path); err != nil {
errs = multierr.Append(errs, NewChallengeTxtError(exercice, 0, err)) errs = multierr.Append(errs, NewChallengeTxtError(exercice, 0, err))
} else if len(params.Flags) == 0 && len(params.FlagsUCQ) == 0 && len(params.FlagsMCQ) == 0 { } else if len(params.Flags) == 0 && len(params.FlagsUCQ) == 0 && len(params.FlagsMCQ) == 0 {
errs = multierr.Append(errs, NewChallengeTxtError(exercice, 0, fmt.Errorf("has no flag"))) if !params.WIP {
errs = multierr.Append(errs, NewChallengeTxtError(exercice, 0, fmt.Errorf("has no flag")))
}
} else { } else {
// Treat legacy UCQ flags as ExerciceFlag // Treat legacy UCQ flags as ExerciceFlag
for _, flag := range params.FlagsUCQ { for _, flag := range params.FlagsUCQ {

View File

@ -60,7 +60,7 @@ func BuildFilesListInto(i Importer, exercice *fic.Exercice, into string) (files
// Parse DIGESTS.txt // Parse DIGESTS.txt
if digs, err := GetFileContent(i, path.Join(exercice.Path, into, "DIGESTS.txt")); err != nil { if digs, err := GetFileContent(i, path.Join(exercice.Path, into, "DIGESTS.txt")); err != nil {
errs = multierr.Append(errs, NewExerciceError(exercice, fmt.Errorf("unable to read %s: %w", path.Join(into, "DIGESTS.txt"), err))) errs = multierr.Append(errs, NewExerciceError(exercice, fmt.Errorf("unable to read %s: %w", path.Join(into, "DIGESTS.txt"), err)))
} else { } else if len(digs) > 0 {
digests = map[string][]byte{} digests = map[string][]byte{}
for nline, d := range strings.Split(digs, "\n") { 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 {

View File

@ -172,10 +172,6 @@ func GetFileContent(i Importer, URI string) (string, error) {
buf = append(buf, b) buf = append(buf, b)
} }
if len(buf) == 0 {
return "", fmt.Errorf("File is empty")
}
return strings.TrimSpace(string(buf)), nil return strings.TrimSpace(string(buf)), nil
} }
} }