X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=mime-node.c;h=8b767d78311732abf48786dade8fb0797a364aa0;hb=0f314c0c99befea599a68bea51d759b4133efef6;hp=bb0870d024ad1f82127e37eeb564578bc9a2695a;hpb=66c9b11bb05e09a7fa2a8ff390190cc16c1499e6;p=notmuch diff --git a/mime-node.c b/mime-node.c index bb0870d0..8b767d78 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) { @@ -92,7 +112,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message, status = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; } - g_mime_stream_file_set_owner (GMIME_STREAM_FILE (mctx->stream), FALSE); + g_mime_stream_file_set_owner (GMIME_STREAM_FILE (mctx->stream), false); mctx->parser = g_mime_parser_new_with_stream (mctx->stream); if (!mctx->parser) { @@ -155,7 +175,7 @@ node_verify (mime_node_t *node, GMimeObject *part, { GError *err = NULL; - node->verify_attempted = TRUE; + node->verify_attempted = true; node->sig_list = g_mime_multipart_signed_verify (GMIME_MULTIPART_SIGNED (part), cryptoctx, &err); @@ -178,7 +198,7 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part, GMimeDecryptResult *decrypt_result = NULL; GMimeMultipartEncrypted *encrypteddata = GMIME_MULTIPART_ENCRYPTED (part); - node->decrypt_attempted = TRUE; + node->decrypt_attempted = true; node->decrypted_child = g_mime_multipart_encrypted_decrypt (encrypteddata, cryptoctx, &decrypt_result, &err); if (! node->decrypted_child) { @@ -187,8 +207,8 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part, goto DONE; } - node->decrypt_success = TRUE; - node->verify_attempted = TRUE; + node->decrypt_success = true; + node->verify_attempted = true; /* This may be NULL if the part is not signed. */ node->sig_list = g_mime_decrypt_result_get_signatures (decrypt_result);