X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=mime-node.c;h=24d73afa84589f9ee49c50b9a82225fd9b76865b;hp=bc41b7523c486f72f48b3b132e9241454c568857;hb=9a0df8128c1a2f92d03035aebbd7a90eb93ec601;hpb=606e320e472b486359cf7a44c488b29e717a3ac8 diff --git a/mime-node.c b/mime-node.c index bc41b752..24d73afa 100644 --- a/mime-node.c +++ b/mime-node.c @@ -79,12 +79,32 @@ mime_node_open (const void *ctx, notmuch_message_t *message, } talloc_set_destructor (mctx, _mime_node_context_free); + /* Fast path */ mctx->file = fopen (filename, "r"); if (! mctx->file) { - fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno)); - status = NOTMUCH_STATUS_FILE_ERROR; - goto DONE; - } + /* Slow path - for some reason the first file in the list is + * not available anymore. This is clearly a problem in the + * database, but we are not going to let this problem be a + * show stopper */ + notmuch_filenames_t *filenames; + for (filenames = notmuch_message_get_filenames (message); + notmuch_filenames_valid (filenames); + notmuch_filenames_move_to_next (filenames)) + { + filename = notmuch_filenames_get (filenames); + mctx->file = fopen (filename, "r"); + if (mctx->file) + break; + } + + talloc_free (filenames); + if (! mctx->file) { + /* Give up */ + fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno)); + status = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } + } mctx->stream = g_mime_stream_file_new (mctx->file); if (!mctx->stream) { @@ -240,6 +260,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part) return NULL; } +#if (GMIME_MAJOR_VERSION < 3) if ((GMIME_IS_MULTIPART_ENCRYPTED (part) && node->ctx->crypto->decrypt) || (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto->verify)) { GMimeContentType *content_type = g_mime_object_get_content_type (part); @@ -248,6 +269,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part) if (!cryptoctx) return NULL; } +#endif /* Handle PGP/MIME parts */ if (GMIME_IS_MULTIPART_ENCRYPTED (part) && node->ctx->crypto->decrypt) {