From de9f686480f3a36aa2ce37490e3c19790af1043c Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 12 Aug 2024 17:18:07 +0200 Subject: [PATCH] fix(migration): ensure project background gets exported and imported (cherry picked from commit ebfd5f54d2e4644aa2076c57a9b50ed5b87deaa9) --- pkg/models/export.go | 5 +++++ pkg/modules/migration/vikunja-file/vikunja.go | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/models/export.go b/pkg/models/export.go index fe3a0e5e8..ad75f6d73 100644 --- a/pkg/models/export.go +++ b/pkg/models/export.go @@ -147,6 +147,11 @@ func exportProjectsAndTasks(s *xorm.Session, u *user.User, wr *zip.Writer) (task projectsMap := make(map[int64]*ProjectWithTasksAndBuckets, len(rawProjects)) projectIDs := []int64{} for _, p := range rawProjects { + if p.BackgroundFileID > 0 { + p.BackgroundInformation = &files.File{ + ID: p.BackgroundFileID, + } + } pp := &ProjectWithTasksAndBuckets{ Project: *p, } diff --git a/pkg/modules/migration/vikunja-file/vikunja.go b/pkg/modules/migration/vikunja-file/vikunja.go index 1cdf5c29f..d05be1671 100644 --- a/pkg/modules/migration/vikunja-file/vikunja.go +++ b/pkg/modules/migration/vikunja-file/vikunja.go @@ -228,7 +228,15 @@ func addDetailsToProjectAndChildren(p *models.ProjectWithTasksAndBuckets, stored } func addDetailsToProject(l *models.ProjectWithTasksAndBuckets, storedFiles map[int64]*zip.File) (err error) { - if b, exists := storedFiles[l.BackgroundFileID]; exists { + var backgroundFileID int64 + bginfo, is := l.BackgroundInformation.(map[string]interface{}) + if is { + bgid, has := bginfo["id"] + if has { + backgroundFileID = int64(bgid.(float64)) + } + } + if b, exists := storedFiles[backgroundFileID]; exists { bf, err := b.Open() if err != nil { return fmt.Errorf("could not open project background file %d for reading: %w", l.BackgroundFileID, err)