Skip to content

Commit

Permalink
do not store metadata with attachment entry in gridstore
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Apr 9, 2017
1 parent e374609 commit 8c7cedc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ server.get('/message/:message/attachment/:attachment', (req, res, next) => {
}

res.writeHead(200, {
'Content-Type': messageData.metadata.contentType
'Content-Type': messageData.contentType || 'application/octet-stream'
});

let attachmentStream = messageHandler.indexer.gridstore.createReadStream(messageData._id);
Expand All @@ -1093,7 +1093,6 @@ server.get('/message/:message/attachment/:attachment', (req, res, next) => {
} else {
attachmentStream.pipe(res);
}

});
});

Expand Down
9 changes: 3 additions & 6 deletions imap-core/lib/indexer/indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,13 @@ class Indexer {
let store = this.gridstore.createWriteStream(attachmentId, {
fsync: true,
content_type: contentType,
// metadata should include only minimally required information, this would allow
// to share attachments between different messages if the content is exactly the same
// even though metadata (filename, content-disposition etc) might not
metadata: {
// if we copy the same message to other mailboxes then instead
// of copying attachments we add a pointer to the new message here
messages: [messageId],
// decoded filename to display in a web client or API
fileName,
// content-type for the attachment
contentType,
// is it really an attachment? maybe it's a very long text part?
disposition,
// how to decode contents if a webclient or API asks for the attachment
transferEncoding
}
Expand Down

0 comments on commit 8c7cedc

Please sign in to comment.