From f4d0e0001cdb783d098ace3db8951ee516c35b6c Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 24 Mar 2024 20:17:25 +0100 Subject: [PATCH] sync: Don't overwrite theme image if it exists --- admin/sync/exercices.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/admin/sync/exercices.go b/admin/sync/exercices.go index e84a5ee6..a5d055b4 100644 --- a/admin/sync/exercices.go +++ b/admin/sync/exercices.go @@ -400,10 +400,15 @@ func SyncExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*f e.BackgroundColor, _ = getBackgroundColor(filePath) // If the theme has no image yet, use the first exercice's image found - theme.Image = e.Image - _, err := theme.Update() + if theme != nil && theme.Image == "" { + theme.Image = e.Image + _, err := theme.Update() + if err != nil { + return nil, err + } + } - return nil, err + return nil, nil }); err != nil { errs = multierr.Append(errs, NewExerciceError(e, fmt.Errorf("unable to import heading image: %w", err))) }