fix(import): don't try to load a nonexistant attachment file
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2023-03-26 15:42:13 +02:00
parent 84c3d0ef6d
commit 823c817b1f
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 6 additions and 1 deletions

View File

@ -141,7 +141,12 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er
comment.ID = 0
}
for _, attachment := range t.Attachments {
af, err := storedFiles[attachment.File.ID].Open()
attachmentFile, exists := storedFiles[attachment.File.ID]
if !exists {
log.Debugf(logPrefix+"Could not find attachment file %d for attachment %d", attachment.File.ID, attachment.ID)
continue
}
af, err := attachmentFile.Open()
if err != nil {
return fmt.Errorf("could not open attachment %d for reading: %w", attachment.ID, err)
}