repochecker: Check gunziped file hash
This commit is contained in:
parent
6ca71230c1
commit
9bcf4a481e
1 changed files with 20 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
|
@ -120,6 +121,25 @@ func CheckExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExc
|
|||
if strings.HasSuffix(fname, ".gz") {
|
||||
if d, exists := digests[strings.TrimSuffix(fname, ".gz")]; exists {
|
||||
digest_shown = d
|
||||
|
||||
// Check that gunzipped file digest is correct
|
||||
if fd, closer, err := GetFile(i, path.Join(exercice.Path, "files", fname)); err != nil {
|
||||
errs = append(errs, NewFileError(exercice, fname, fmt.Errorf("unable to read file: %w", err)))
|
||||
continue
|
||||
} else if gunzipfd, err := gzip.NewReader(fd); err != nil {
|
||||
closer()
|
||||
errs = append(errs, NewFileError(exercice, fname, fmt.Errorf("unable to gunzip file: %w", err)))
|
||||
continue
|
||||
} else {
|
||||
defer gunzipfd.Close()
|
||||
defer closer()
|
||||
|
||||
hash160_inflate, hash512_inflate := fic.CreateHashBuffers(gunzipfd)
|
||||
|
||||
if _, err := fic.CheckBufferHash(hash160_inflate, hash512_inflate, digest_shown); err != nil {
|
||||
errs = append(errs, NewFileError(exercice, strings.TrimSuffix(fname, ".gz"), err))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue