Skip to content

Commit e1dbb65

Browse files
author
Carsten Seeger
committed
fixed issue when uploading same file under different name
1 parent 7325395 commit e1dbb65

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/mailparse.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,8 @@ func (m Mail2Most) parseAttachment(body []byte, header string) (Attachment, erro
213213

214214
sum := sha256.Sum256(body)
215215
if _, ok := seenAttachments[sum]; ok {
216-
// throwing an error here is a bit strange it would be better to return the existing attachment
217216
// btw this could be exploited by creating a hash colision :D
218-
return Attachment{}, errors.New("attachment already exists")
217+
return Attachment{Filename: seenAttachments[sum], Content: body}, nil
219218
}
220219

221220
seenAttachments[sum] = filename

0 commit comments

Comments
 (0)