sync: Report custom errors
This commit is contained in:
parent
08ea1bac0d
commit
c78545c18b
17 changed files with 510 additions and 137 deletions
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
@ -22,6 +23,7 @@ var (
|
|||
ignoreBinaryFileUnder = 1500000
|
||||
skipFileChecks = false
|
||||
skipBinaryFileCheck = false
|
||||
logMissingResolution = false
|
||||
)
|
||||
|
||||
func formatFileSize(size int) string {
|
||||
|
@ -145,6 +147,7 @@ func main() {
|
|||
cloudUsername := "fic"
|
||||
cloudPassword := ""
|
||||
localImporterDirectory := ""
|
||||
checkplugins := sync.CheckPluginList{}
|
||||
|
||||
// Read paremeters from environment
|
||||
if v, exists := os.LookupEnv("FICCLOUD_URL"); exists {
|
||||
|
@ -167,9 +170,10 @@ func main() {
|
|||
flag.BoolVar(&fic.OptionalDigest, "optionaldigest", fic.OptionalDigest, "Is the digest required when importing files?")
|
||||
flag.BoolVar(&fic.StrongDigest, "strongdigest", fic.StrongDigest, "Are BLAKE2b digests required or is SHA-1 good enough?")
|
||||
flag.BoolVar(&skipFileChecks, "skipfiledigests", skipFileChecks, "Don't perform DIGESTS checks on file to speed up the checks")
|
||||
flag.BoolVar(&sync.LogMissingResolution, "skipresolution", sync.LogMissingResolution, "Don't fail if resolution.mp4 is absent")
|
||||
flag.BoolVar(&logMissingResolution, "skipresolution", logMissingResolution, "Don't fail if resolution.mp4 is absent")
|
||||
flag.BoolVar(&skipBinaryFileCheck, "skip-binary-file", skipBinaryFileCheck, "In Git-LFS check, don't warn files")
|
||||
flag.IntVar(&ignoreBinaryFileUnder, "skip-binary-files-under", ignoreBinaryFileUnder, "In Git-LFS check, don't warn files under this size")
|
||||
flag.Var(&checkplugins, "rules-plugins", "List of libraries containing others rules to checks")
|
||||
flag.Parse()
|
||||
|
||||
// Do not display timestamp
|
||||
|
@ -211,6 +215,15 @@ func main() {
|
|||
log.Fatal("No importer nor path given!")
|
||||
}
|
||||
|
||||
// Load rules plugins
|
||||
for _, p := range checkplugins {
|
||||
if err := sync.LoadChecksPlugin(p); err != nil {
|
||||
log.Fatalf("Unable to load rule plugin %q: %s", p, err.Error())
|
||||
} else {
|
||||
log.Printf("Rules plugin %q successfully loaded", p)
|
||||
}
|
||||
}
|
||||
|
||||
// Variable that handles the exit status
|
||||
hasError := false
|
||||
|
||||
|
@ -248,8 +261,17 @@ func main() {
|
|||
|
||||
for _, edir := range exercices {
|
||||
for _, err := range checkExercice(theme, edir, &dmap) {
|
||||
nberr += 1
|
||||
log.Println(err.Error())
|
||||
|
||||
if logMissingResolution {
|
||||
if e, ok := err.(*sync.ExerciceError); ok {
|
||||
if errors.Is(e.GetError(), sync.ErrResolutionNotFound) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nberr += 1
|
||||
}
|
||||
log.Printf("================================== Exercice %q treated\n", edir)
|
||||
}
|
||||
|
|
Reference in a new issue