admin: able to sync splitted files

This commit is contained in:
nemunaire 2017-12-12 07:11:01 +01:00 committed by Pierre-Olivier Mercier
parent b4057c1a2c
commit a543be0255
1 changed files with 32 additions and 2 deletions

View File

@ -34,9 +34,39 @@ func SyncExerciceFiles(i Importer, exercice fic.Exercice) []string {
}
}
// Import files
// Import splitted files
var splittedFiles []string
for _, fname := range files {
if _, err := ImportFile(path.Join(exercice.Path, "files", fname),
if matched, _ := path.Match("*.00", fname); matched {
fname = fname[:len(fname)-3]
splittedFiles = append(splittedFiles, fname + ".[0-9][0-9]")
files = append(files, fname)
} else if matched, _ := path.Match("*00", fname); matched {
fname = fname[:len(fname)-2]
splittedFiles = append(splittedFiles, fname + "[0-9][0-9]")
files = append(files, fname)
} else if matched, _ := path.Match("*_MERGED", fname); matched {
splittedFiles = append(splittedFiles, fname)
}
}
// Import standard files
for _, fname := range files {
if fname == "DIGESTS.txt" {
continue
}
foundSplitted := false
for _, sf := range splittedFiles {
if matched, _ := path.Match(sf, fname); matched {
foundSplitted = true
}
}
if foundSplitted {
continue
}
if _, err := i.importFile(path.Join(exercice.Path, "files", fname),
func(filePath string, origin string) (interface{}, error) {
return exercice.ImportFile(filePath, origin, digests[fname])
}); err != nil {