implement RFE 3238, 'GPG Mime Plugin exports contents to a tmpfile unnecessarily'
authorPaul <paul@claws-mail.org>
Fri, 1 Aug 2014 05:50:50 +0000 (06:50 +0100)
committerPaul <paul@claws-mail.org>
Fri, 1 Aug 2014 05:50:50 +0000 (06:50 +0100)
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>

AUTHORS
src/gtk/authors.h
src/plugins/pgpcore/sgpgme.c

diff --git a/AUTHORS b/AUTHORS
index 3afe31e2a23becd8d4784893f02f9eb26db05b2d..04b8f751314d2312671e62da17168a1ab8df3152 100644 (file)
--- 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
index a1d6e13e3eaac3d32aa9d65cb398a39a75ed639a..cbfc14df53d13b967ff00b48f9811a62723dd676 100644 (file)
@@ -108,6 +108,7 @@ static char *CONTRIBS_LIST[] = {
 "Christian Cornelssen",
 "Palmer Dabbelt",
 "George Danchev",
+"Kevin Day",
 "Matthieu Dazy",
 "Ben Deering",
 "Pierric Descamps",
index ede5f83223430b613e48b276089f01cbca2c7266..b247eb78c9dc2ccd8f60ff56a7eeb5df6a8c58e5 100644 (file)
@@ -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) {