Do not fail export on email attachments without name (#23)
* Do not fail on email attachments without name * Add changelog entry * Allow posts to also have unnamed attachments
This commit is contained in:
parent
6aab750b7f
commit
aa2f0049e1
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Handle the case where an email or event cannot be retrieved from Exchange due to an `ErrorCorruptData` error. Corso will skip over the item but report it in the backup summary.
|
||||
- Emails attached within other emails are now correctly exported
|
||||
- Use correct timezone for event start and end times in Exchange exports (helps fix issues in relative recurrence patterns)
|
||||
- Gracefully handle email and post attachments without name when exporting to eml
|
||||
|
||||
## [v0.19.0] (beta) - 2024-02-06
|
||||
|
||||
|
||||
@ -171,6 +171,13 @@ func getFileAttachment(ctx context.Context, attachment models.Attachmentable) (*
|
||||
}
|
||||
|
||||
name := ptr.Val(attachment.GetName())
|
||||
if len(name) == 0 {
|
||||
// Graph as of now does not let us create any attachments
|
||||
// without a name, but we have run into instances where we have
|
||||
// see attachments without a name, possibly from old
|
||||
// data. This is for those cases.
|
||||
name = "Unnamed"
|
||||
}
|
||||
|
||||
contentID, err := attachment.GetBackingStore().Get("contentId")
|
||||
if err != nil {
|
||||
@ -472,6 +479,9 @@ func FromJSONPostToEML(
|
||||
}
|
||||
|
||||
name := ptr.Val(attachment.GetName())
|
||||
if len(name) == 0 {
|
||||
name = "Unnamed"
|
||||
}
|
||||
|
||||
contentID, err := attachment.GetBackingStore().Get("contentId")
|
||||
if err != nil {
|
||||
|
||||
@ -162,6 +162,18 @@ func (suite *EMLUnitSuite) TestConvert_edge_cases() {
|
||||
require.NoError(suite.T(), err, "setting attachment content")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "attachment without name",
|
||||
transform: func(msg models.Messageable) {
|
||||
attachments := msg.GetAttachments()
|
||||
attachments[1].SetName(ptr.To(""))
|
||||
|
||||
// This test has to be run on a non inline attachment
|
||||
// as inline attachments use contentID instead of name
|
||||
// even when there is a name.
|
||||
assert.False(suite.T(), ptr.Val(attachments[1].GetIsInline()))
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user