Actually make the "write attachments" feature in d16957d work

This is a follow-up to my pull request #895 which fixes another bug in
pull request #831 (d16957d).

The code to write out the attachments would never work, for what it's
worth it's clear from the issue I fixed in #895 that the codepath had
never been executed as-is.

It would find the attachments and try to write them out to /tmp/, just
that, no /tmp/NAME, just the directory itself. That would yield an
error of trying to write to a directory.

Fix that, now we create a temporary name as a function of the
attachment and both save it and extract it.

This makes the mu4e-action-view-in-browser function finally work for
me. It'll now write out the attachments to /tmp, and rewrite the HTML
so that I'll see the attachments in my browser.
This commit is contained in:
Ævar Arnfjörð Bjarmason 2016-08-01 21:11:05 +02:00
parent 5189e6bac7
commit e2ce627197
1 changed files with 3 additions and 2 deletions

View File

@ -93,8 +93,9 @@ return the filename."
(if (plist-get attachment :temp)
(replace-match (format "src=\"%s\"" (plist-get attachment :temp)))
(replace-match (format "src=\"%s%s\"" temporary-file-directory (plist-get attachment :name)))
(mu4e~proc-extract 'save (mu4e-message-field msg :docid) (plist-get attachment :index) mu4e-decryption-policy temporary-file-directory)
(mu4e-remove-file-later (format "%s%s" temporary-file-directory (plist-get attachment :name))))))
(let ((tmp-attachment-name (format "%s%s" temporary-file-directory (plist-get attachment :name))))
(mu4e~proc-extract 'save (mu4e-message-field msg :docid) (plist-get attachment :index) mu4e-decryption-policy tmp-attachment-name)
(mu4e-remove-file-later tmp-attachment-name)))))
attachments)
(save-buffer)
tmpfile)))