repochecker: add new option -skipfiledigests to speed up the checks and avoid downloading lots of content
This commit is contained in:
parent
aee3500fdf
commit
769158a9d7
3 changed files with 44 additions and 10 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
func buildFilesListInto(i Importer, exercice fic.Exercice, into string) (files []string, digests map[string][]byte, errs []string) {
|
||||
func BuildFilesListInto(i Importer, exercice fic.Exercice, into string) (files []string, digests map[string][]byte, errs []string) {
|
||||
// If no files directory, don't display error
|
||||
if !i.exists(path.Join(exercice.Path, into)) {
|
||||
return
|
||||
|
@ -69,9 +69,33 @@ func buildFilesListInto(i Importer, exercice fic.Exercice, into string) (files [
|
|||
return
|
||||
}
|
||||
|
||||
// CheckExerciceFilesPresence limits remote checks to presence, don't get it to check digest.
|
||||
func CheckExerciceFilesPresence(i Importer, exercice fic.Exercice) (files []string, errs []string) {
|
||||
flist, digests, berrs := BuildFilesListInto(i, exercice, "files")
|
||||
errs = append(errs, berrs...)
|
||||
|
||||
for _, fname := range flist {
|
||||
if !i.exists(path.Join(exercice.Path, "files", fname)) {
|
||||
errs = append(errs, fmt.Sprintf("%q: unable to read file %q: No such file or directory", path.Base(exercice.Path), fname))
|
||||
} else if _, ok := digests[fname]; !ok {
|
||||
errs = append(errs, fmt.Sprintf("%q: unable to import file %q: No digest given", path.Base(exercice.Path), fname))
|
||||
} else {
|
||||
files = append(files, fname)
|
||||
}
|
||||
}
|
||||
|
||||
for fname := range digests {
|
||||
if !i.exists(path.Join(exercice.Path, "files", fname)) {
|
||||
errs = append(errs, fmt.Sprintf("%q: unable to read file %q: No such file or directory. Check your DIGESTS.txt for legacy entries.", path.Base(exercice.Path), fname))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CheckExerciceFiles checks that remote files have the right digest.
|
||||
func CheckExerciceFiles(i Importer, exercice fic.Exercice) (files []fic.EFile, errs []string) {
|
||||
flist, digests, berrs := buildFilesListInto(i, exercice, "files")
|
||||
func CheckExerciceFiles(i Importer, exercice fic.Exercice) (files []string, errs []string) {
|
||||
flist, digests, berrs := BuildFilesListInto(i, exercice, "files")
|
||||
errs = append(errs, berrs...)
|
||||
|
||||
for _, fname := range flist {
|
||||
|
@ -84,7 +108,7 @@ func CheckExerciceFiles(i Importer, exercice fic.Exercice) (files []fic.EFile, e
|
|||
errs = append(errs, fmt.Sprintf("%q: %s: %s", path.Base(exercice.Path), fname, err))
|
||||
}
|
||||
|
||||
files = append(files, fic.EFile{Name: fname})
|
||||
files = append(files, fname)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -96,7 +120,7 @@ func SyncExerciceFiles(i Importer, exercice fic.Exercice) (errs []string) {
|
|||
errs = append(errs, err.Error())
|
||||
}
|
||||
|
||||
files, digests, berrs := buildFilesListInto(i, exercice, "files")
|
||||
files, digests, berrs := BuildFilesListInto(i, exercice, "files")
|
||||
errs = append(errs, berrs...)
|
||||
|
||||
// Import standard files
|
||||
|
|
Reference in a new issue