admin/sync: Also handle uncompressed file in CheckExerciceFiles
This commit is contained in:
parent
5b47d1c250
commit
ae1378780f
2 changed files with 10 additions and 3 deletions
|
@ -112,7 +112,14 @@ func CheckExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExc
|
||||||
} else if size, err := getFileSize(i, path.Join(exercice.Path, "files", fname)); err != nil {
|
} else if size, err := getFileSize(i, path.Join(exercice.Path, "files", fname)); err != nil {
|
||||||
errs = append(errs, NewFileError(exercice, fname, err))
|
errs = append(errs, NewFileError(exercice, fname, err))
|
||||||
} else {
|
} else {
|
||||||
file := exercice.NewDummyFile(path.Join(exercice.Path, "files", fname), getDestinationFilePath(path.Join(exercice.Path, "files", fname)), (*hash512).Sum(nil), size)
|
var digest_shown []byte
|
||||||
|
if strings.HasSuffix(fname, ".gz") {
|
||||||
|
if d, exists := digests[strings.TrimSuffix(fname, ".gz")]; exists {
|
||||||
|
digest_shown = d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file := exercice.NewDummyFile(path.Join(exercice.Path, "files", fname), getDestinationFilePath(path.Join(exercice.Path, "files", fname)), (*hash512).Sum(nil), digest_shown, size)
|
||||||
|
|
||||||
// Call checks hooks
|
// Call checks hooks
|
||||||
for _, h := range hooks.fileHooks {
|
for _, h := range hooks.fileHooks {
|
||||||
|
|
|
@ -50,7 +50,7 @@ type EFile struct {
|
||||||
|
|
||||||
// NewDummyFile creates an EFile, without any link to an actual Exercice File.
|
// NewDummyFile creates an EFile, without any link to an actual Exercice File.
|
||||||
// It is used to check the file validity
|
// It is used to check the file validity
|
||||||
func (e *Exercice) NewDummyFile(origin string, dest string, checksum []byte, size int64) *EFile {
|
func (e *Exercice) NewDummyFile(origin string, dest string, checksum []byte, checksumShown []byte, size int64) *EFile {
|
||||||
return &EFile{
|
return &EFile{
|
||||||
Id: 0,
|
Id: 0,
|
||||||
origin: origin,
|
origin: origin,
|
||||||
|
@ -58,7 +58,7 @@ func (e *Exercice) NewDummyFile(origin string, dest string, checksum []byte, siz
|
||||||
IdExercice: e.Id,
|
IdExercice: e.Id,
|
||||||
Name: path.Base(origin),
|
Name: path.Base(origin),
|
||||||
Checksum: checksum,
|
Checksum: checksum,
|
||||||
ChecksumShown: nil,
|
ChecksumShown: checksumShown,
|
||||||
Size: size,
|
Size: size,
|
||||||
Published: true,
|
Published: true,
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue