Perform full deep synchronisation
This commit is contained in:
parent
9225038ffa
commit
6ef91a92e5
@ -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
27
admin/sync/full.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user