2022-11-03 01:32:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
|
2023-11-22 11:16:53 +00:00
|
|
|
"go.uber.org/multierr"
|
|
|
|
|
2022-11-03 01:32:27 +00:00
|
|
|
"srs.epita.fr/fic-server/admin/sync"
|
|
|
|
"srs.epita.fr/fic-server/libfic"
|
|
|
|
)
|
|
|
|
|
2023-11-22 11:16:53 +00:00
|
|
|
func InspectFile(file *fic.EFile, _ *fic.Exercice, exceptions *sync.CheckExceptions) (errs error) {
|
2022-11-03 01:32:27 +00:00
|
|
|
if filepath.Ext(file.Name) == ".tar" || strings.HasSuffix(file.Name, ".tar.gz") || strings.HasSuffix(file.Name, ".tar.bz2") {
|
2022-11-21 17:39:11 +00:00
|
|
|
// Check there is more than 1 file in tarball
|
2023-11-22 11:16:53 +00:00
|
|
|
errs = multierr.Append(errs, checkTarball(file, exceptions))
|
2022-11-21 17:39:11 +00:00
|
|
|
} else if filepath.Ext(file.Name) == ".zip" {
|
|
|
|
// Check there is more than 1 file in zip
|
2023-11-22 11:16:53 +00:00
|
|
|
errs = multierr.Append(errs, checkZip(file, exceptions))
|
2022-11-03 01:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|