admin: Refactor sync/auto
This commit is contained in:
parent
abd91012f8
commit
63cf665f2d
@ -224,32 +224,39 @@ func autoSync(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var theTheme *fic.Theme
|
||||
|
||||
for _, theme := range themes {
|
||||
if theme.Path == p {
|
||||
if !IsProductionEnv {
|
||||
exercices, err := theme.GetExercices()
|
||||
if err == nil {
|
||||
for _, exercice := range exercices {
|
||||
exercice.DeleteDeep()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exceptions := sync.LoadException(sync.GlobalImporter, theme)
|
||||
|
||||
var st []string
|
||||
for _, se := range sync.SyncThemeDeep(sync.GlobalImporter, theme, 0, 250, exceptions) {
|
||||
st = append(st, se.Error())
|
||||
}
|
||||
sync.EditDeepReport(&sync.SyncReport{Themes: map[string][]string{theme.Name: st}}, false)
|
||||
sync.DeepSyncProgress = 255
|
||||
|
||||
settings.ForceRegeneration()
|
||||
|
||||
c.JSON(http.StatusOK, st)
|
||||
return
|
||||
theTheme = theme
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": fmt.Sprintf("Theme not found %q", p)})
|
||||
if theTheme == nil {
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": fmt.Sprintf("Theme not found %q", p)})
|
||||
return
|
||||
}
|
||||
|
||||
if !IsProductionEnv {
|
||||
exercices, err := theTheme.GetExercices()
|
||||
if err == nil {
|
||||
for _, exercice := range exercices {
|
||||
exercice.DeleteDeep()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exceptions := sync.LoadException(sync.GlobalImporter, theTheme)
|
||||
|
||||
var st []string
|
||||
for _, se := range sync.SyncThemeDeep(sync.GlobalImporter, theTheme, 0, 250, exceptions) {
|
||||
st = append(st, se.Error())
|
||||
}
|
||||
sync.EditDeepReport(&sync.SyncReport{Themes: map[string][]string{theTheme.Name: st}}, false)
|
||||
sync.DeepSyncProgress = 255
|
||||
|
||||
settings.ForceRegeneration()
|
||||
|
||||
c.JSON(http.StatusOK, st)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user