server/repochecker/epita/files.go

25 lines
650 B
Go
Raw Normal View History

2022-07-11 17:57:33 +00:00
package main
import (
"fmt"
"path"
"strings"
2022-07-11 17:57:33 +00:00
"srs.epita.fr/fic-server/admin/sync"
2022-07-11 17:57:33 +00:00
"srs.epita.fr/fic-server/libfic"
)
func EPITACheckFile(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error) {
2022-07-11 17:57:33 +00:00
// Enforce file format
if path.Ext(file.Name) == "rar" || path.Ext(file.Name) == "7z" {
errs = append(errs, fmt.Errorf("this file use a forbidden archive type."))
}
// Check .gz files have a dedicated hash
if path.Ext(file.Name) == ".gz" && !strings.HasSuffix(file.Name, ".tar.gz") && len(file.ChecksumShown) == 0 {
errs = append(errs, fmt.Errorf("digest of original, uncompressed, file missing in DIGESTS.txt"))
}
2022-07-11 17:57:33 +00:00
return
}