fileexporter: Include standalone exercices
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2025-04-07 11:19:44 +02:00
commit 961542283d
3 changed files with 19 additions and 14 deletions

View file

@ -72,13 +72,9 @@ func SpeedySyncDeep(i Importer) (errs SyncReport) {
errs.ThemesSync = append(errs.ThemesSync, sterr.Error())
}
if themes, err := fic.GetThemes(); err == nil {
if themes, err := fic.GetThemesExtended(); err == nil {
DeepSyncProgress = 2
if i.Exists(fic.StandaloneExercicesDirectory) {
themes = append(themes, &fic.StandaloneExercicesTheme)
}
var themeStep uint8 = uint8(250) / uint8(len(themes))
for tid, theme := range themes {
@ -143,14 +139,9 @@ func SyncDeep(i Importer) (errs SyncReport) {
}
// Synchronize themes
if themes, err := fic.GetThemes(); err == nil {
if themes, err := fic.GetThemesExtended(); err == nil {
DeepSyncProgress = 2
// Also synchronize standalone exercices
if i.Exists(fic.StandaloneExercicesDirectory) {
themes = append(themes, &fic.StandaloneExercicesTheme)
}
var themeStep uint8 = uint8(250) / uint8(len(themes))
for tid, theme := range themes {

View file

@ -40,6 +40,20 @@ func GetThemes(i Importer) (themes []string, err error) {
return themes, nil
}
// GetThemesExtended returns all theme directories, including standalone exercices.
func GetThemesExtended(i Importer) (themes []string, err error) {
themes, err = GetThemes(i)
if err != nil {
return
}
if i.Exists(fic.StandaloneExercicesDirectory) {
themes = append(themes, fic.StandaloneExercicesDirectory)
}
return
}
// resizePicture makes the given image just fill the given rectangle.
func resizePicture(i Importer, imgPath string, importedPath string, rect image.Rectangle) error {
if fl, err := i.GetFile(imgPath); err != nil {