Perform full deep synchronisation

This commit is contained in:
nemunaire 2017-12-09 10:54:16 +01:00 committed by Pierre-Olivier Mercier
parent 9225038ffa
commit 6ef91a92e5
2 changed files with 29 additions and 0 deletions

View File

@ -45,6 +45,8 @@ func init() {
router.GET("/api/remote/themes/:thid/exercices", apiHandler(themeHandler(sync.ApiListRemoteExercices)))
// Synchronize
router.GET("/api/sync/deep", apiHandler(
func(_ httprouter.Params, _ []byte) (interface{}, error) { return sync.SyncDeep(sync.GlobalImporter), nil }))
router.GET("/api/sync/themes", apiHandler(
func(_ httprouter.Params, _ []byte) (interface{}, error) { return sync.SyncThemes(sync.GlobalImporter), nil }))
router.GET("/api/sync/themes/:thid/exercices", apiHandler(themeHandler(

27
admin/sync/full.go Normal file
View File

@ -0,0 +1,27 @@
package sync
import (
"srs.epita.fr/fic-server/libfic"
)
func SyncDeep(i Importer) map[string][]string {
errs := map[string][]string{}
errs["_themes"] = SyncThemes(i)
if themes, err := fic.GetThemes(); err == nil {
for _, theme := range themes {
errs[theme.Name] = SyncExercices(i, theme)
if exercices, err := theme.GetExercices(); err == nil {
for _, exercice := range exercices {
errs[theme.Name] = append(errs[theme.Name], SyncExerciceFiles(i, exercice)...)
errs[theme.Name] = append(errs[theme.Name], SyncExerciceHints(i, exercice)...)
errs[theme.Name] = append(errs[theme.Name], SyncExerciceKeys(i, exercice)...)
}
}
}
}
return errs
}