repochecker/epita: Ask to compress huge files

This commit is contained in:
nemunaire 2022-11-03 02:28:45 +01:00
parent 76ee40b7f1
commit 7a800b10de
1 changed files with 21 additions and 0 deletions

View File

@ -15,10 +15,31 @@ func EPITACheckFile(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []e
errs = append(errs, fmt.Errorf("this file use a forbidden archive type."))
}
// Check for stange file extension
if strings.HasSuffix(file.Name, ".tar.zip") {
errs = append(errs, fmt.Errorf(".tar.zip is not a valid tar format"))
}
// 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"))
}
// Check for huge file to compress
if file.Size > 4000000 && path.Ext(file.Name) == ".tar" {
errs = append(errs, fmt.Errorf("archive to compress with bzip2"))
} else if file.Size > 40000000 && (path.Ext(file.Name) == "" ||
path.Ext(file.Name) == ".csv" ||
path.Ext(file.Name) == ".dump" ||
path.Ext(file.Name) == ".eml" ||
path.Ext(file.Name) == ".json" ||
path.Ext(file.Name) == ".log" ||
path.Ext(file.Name) == ".mbox" ||
path.Ext(file.Name) == ".pcap" ||
path.Ext(file.Name) == ".pcapng" ||
path.Ext(file.Name) == ".txt") {
errs = append(errs, fmt.Errorf("huge file to compress with gzip"))
}
return
}