From d522d407731d9e4d600526024dbe397d8362b839 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 21 Mar 2025 18:03:27 +0100 Subject: [PATCH] fix(migration): do not fail when an attachment is too large Resolves https://vikunja.sentry.io/issues/6389417364/events/d79bdea146b54a9dace8c81e3f787975/ --- pkg/modules/migration/create_from_structure.go | 4 ++++ pkg/modules/migration/vikunja-file/vikunja.go | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/modules/migration/create_from_structure.go b/pkg/modules/migration/create_from_structure.go index 64c12ffb4..5f28a1f54 100644 --- a/pkg/modules/migration/create_from_structure.go +++ b/pkg/modules/migration/create_from_structure.go @@ -382,6 +382,10 @@ func createProjectWithEverything(s *xorm.Session, project *models.ProjectWithTas fr := io.NopCloser(bytes.NewReader(a.File.FileContent)) err = a.NewAttachment(s, fr, a.File.Name, a.File.Size, user) if err != nil { + if models.IsErrTaskAttachmentIsTooLarge(err) { + log.Warningf("[creating structure] Attachment %s is too large (%d bytes), skipping: %v", a.File.Name, a.File.Size, err) + continue + } return } log.Debugf("[creating structure] Created new attachment %d", a.ID) diff --git a/pkg/modules/migration/vikunja-file/vikunja.go b/pkg/modules/migration/vikunja-file/vikunja.go index e64206bcf..96a0a54b5 100644 --- a/pkg/modules/migration/vikunja-file/vikunja.go +++ b/pkg/modules/migration/vikunja-file/vikunja.go @@ -267,11 +267,13 @@ func addDetailsToProject(l *models.ProjectWithTasksAndBuckets, storedFiles map[i } af, err := attachmentFile.Open() if err != nil { - return fmt.Errorf("could not open attachment %d for reading: %w", attachment.ID, err) + log.Warningf(logPrefix+"Could not open attachment %d for reading: %v, skipping", attachment.ID, err) + continue } var buf bytes.Buffer if _, err := buf.ReadFrom(af); err != nil { - return fmt.Errorf("could not read attachment %d: %w", attachment.ID, err) + log.Warningf(logPrefix+"Could not read attachment %d: %v, skipping", attachment.ID, err) + continue } attachment.ID = 0