admin: auto-sync tries to sync themes if it doesn't exists yet

This commit is contained in:
nemunaire 2023-05-05 12:03:35 +02:00
parent 63cf665f2d
commit 75eae43f60

View File

@ -234,8 +234,30 @@ func autoSync(c *gin.Context) {
}
if theTheme == nil {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": fmt.Sprintf("Theme not found %q", p)})
return
// The theme doesn't exists locally, perhaps it has not been imported already?
rThemes, err := sync.GetThemes(sync.GlobalImporter)
if err == nil {
for _, theme := range rThemes {
if theme == p {
sync.SyncThemes(sync.GlobalImporter)
themes, err := fic.GetThemes()
if err == nil {
for _, theme := range themes {
if theme.Path == p {
theTheme = theme
break
}
}
}
}
}
}
if theTheme == nil {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": fmt.Sprintf("Theme not found %q", p)})
return
}
}
if !IsProductionEnv {