talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit ee35990fd9dac7032e86a107ae84c4ef22f0a444
parent 6e2217d5bb5722a5426158f49bcaed95005a28f6
Author: Paul <paul@claws-mail.org>
Date:   Fri,  1 Aug 2014 06:50:50 +0100

implement RFE 3238, 'GPG Mime Plugin exports contents to a tmpfile unnecessarily'

The function gpgme_data_new_from_filepart() accepts a file stream with an offset.
This information is already available via the mimeinfo variable.
Instead of creating a new, temporary, file that contains some of the gpgme data, just use the original file as is.
This saves resources especially on flash disks that have a limited number of writes.

Patch by Kevin Day <thekevinday@gmail.com>

Diffstat:
MAUTHORS | 1+
Msrc/gtk/authors.h | 1+
Msrc/plugins/pgpcore/sgpgme.c | 10+---------
3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -306,3 +306,4 @@ contributors (in addition to the above; based on Changelog) Peter Sarvas Christoph Ruegge Igor Gnatenko + Kevin Day diff --git a/src/gtk/authors.h b/src/gtk/authors.h @@ -108,6 +108,7 @@ static char *CONTRIBS_LIST[] = { "Christian Cornelssen", "Palmer Dabbelt", "George Danchev", +"Kevin Day", "Matthieu Dazy", "Ben Deering", "Pierric Descamps", diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c @@ -401,15 +401,7 @@ gpgme_data_t sgpgme_data_from_mimeinfo(MimeInfo *mimeinfo) if (!fp) return NULL; - tmp_file = get_tmp_file(); - copy_file_part(fp, mimeinfo->offset, mimeinfo->length, tmp_file); - fclose(fp); - fp = NULL; - debug_print("tmp file %s\n", tmp_file); - - err = gpgme_data_new_from_file(&data, tmp_file, 1); - claws_unlink(tmp_file); - g_free(tmp_file); + err = gpgme_data_new_from_filepart(&data, NULL, fp, mimeinfo->offset, mimeinfo->length); debug_print("data %p (%d %d)\n", (void *)&data, mimeinfo->offset, mimeinfo->length); if (err) {