fix(migration): do not fail when an attachment is too large
Resolves https://vikunja.sentry.io/issues/6389417364/events/d79bdea146b54a9dace8c81e3f787975/
This commit is contained in:
parent
23d2814b94
commit
d522d40773
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue