* Support gzipped message file
@ 2019-03-30 14:06 David Bremner
2019-03-30 14:06 ` [PATCH 1/3] util/gmime-extra: add g_mime_stream_gzfile_{new, open} David Bremner
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: David Bremner @ 2019-03-30 14:06 UTC (permalink / raw)
To: notmuch
This obsoletes the WIP series id:20190324033244.12909-2-david@tethera.net
Compared to the WIP version, this has some general cleanup, and a
switch to using an open file descriptor to create a stream rather than
a FILE*.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] util/gmime-extra: add g_mime_stream_gzfile_{new, open}
2019-03-30 14:06 Support gzipped message file David Bremner
@ 2019-03-30 14:06 ` David Bremner
2019-03-30 14:06 ` [PATCH 2/3] lib/message_file: open gzipped files David Bremner
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: David Bremner @ 2019-03-30 14:06 UTC (permalink / raw)
To: notmuch
These are usable as standard GMime streams, and transparently
decompress gzipped files.
---
| 56 ++++++++++++++++++++++++++++++++++++++++++++++
| 8 +++++++
2 files changed, 64 insertions(+)
--git a/util/gmime-extra.c b/util/gmime-extra.c
index bc1e3c4d..b3f91c55 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -1,6 +1,62 @@
#include "gmime-extra.h"
#include <string.h>
+static
+GMimeStream *
+_gzfile_maybe_filter (GMimeStream *file_stream) {
+ char buf[4];
+ int bytes_read;
+
+ if ((bytes_read = g_mime_stream_read (file_stream, buf, sizeof (buf))) < 0)
+ return NULL;
+
+ if (g_mime_stream_reset (file_stream))
+ return NULL;
+
+ /* check for gzipped input */
+ if (bytes_read >= 2 && buf[0] == 0x1f && (unsigned char)buf[1] == 0x8b) {
+ GMimeStream *gzstream;
+ GMimeFilter *gzfilter;
+
+ gzfilter = g_mime_filter_gzip_new (GMIME_FILTER_GZIP_MODE_UNZIP, 0);
+ if (! gzfilter)
+ return NULL;
+
+ gzstream = g_mime_stream_filter_new (file_stream);
+ if (! gzstream)
+ return NULL;
+
+ g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter);
+ return gzstream;
+ } else {
+ return file_stream;
+ }
+}
+
+GMimeStream *
+g_mime_stream_gzfile_new (int fd)
+{
+ GMimeStream *file_stream;
+
+ file_stream = g_mime_stream_fs_new (fd);
+ if (! file_stream)
+ return NULL;
+
+ return _gzfile_maybe_filter (file_stream);
+}
+
+GMimeStream *
+g_mime_stream_gzfile_open (const char *filename)
+{
+ GMimeStream *file_stream;
+
+ file_stream = g_mime_stream_fs_open (filename, 0, 0, NULL);
+ if (! file_stream)
+ return NULL;
+
+ return _gzfile_maybe_filter (file_stream);
+}
+
GMimeStream *
g_mime_stream_stdout_new()
{
--git a/util/gmime-extra.h b/util/gmime-extra.h
index 5d8c52f7..cb8f5e33 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -9,6 +9,14 @@ extern "C" {
GMimeStream *g_mime_stream_stdout_new(void);
+/* Return a GMime stream for this open file descriptor, un-gzipping if
+ * necessary */
+GMimeStream *g_mime_stream_gzfile_new (int fd);
+
+/* Return a GMime stream for this path, un-gzipping if
+ * necessary */
+GMimeStream *g_mime_stream_gzfile_open (const char *filename);
+
#if (GMIME_MAJOR_VERSION < 3)
#define GMIME_ADDRESS_TYPE_TO GMIME_RECIPIENT_TYPE_TO
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] lib/message_file: open gzipped files
2019-03-30 14:06 Support gzipped message file David Bremner
2019-03-30 14:06 ` [PATCH 1/3] util/gmime-extra: add g_mime_stream_gzfile_{new, open} David Bremner
@ 2019-03-30 14:06 ` David Bremner
2019-03-30 14:06 ` [PATCH 3/3] cli/notmuch-show: support " David Bremner
2019-04-30 17:24 ` Support gzipped message file David Bremner
3 siblings, 0 replies; 7+ messages in thread
From: David Bremner @ 2019-03-30 14:06 UTC (permalink / raw)
To: notmuch
Rather than storing the lower level stdio FILE object, we store a
GMime stream. This allows both transparent decompression, and passing
the stream into GMime for parsing. As a side effect, we can let GMime
close the underlying OS stream (indeed, that stream isn't visible here
anymore).
This change is enough to get notmuch-{new,search} working, but there is still
some work required for notmuch-show, to be done in a following commit.
---
lib/message-file.c | 31 ++++--------
test/T740-gzip.sh | 115 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 125 insertions(+), 21 deletions(-)
create mode 100755 test/T740-gzip.sh
diff --git a/lib/message-file.c b/lib/message-file.c
index 8f0dbbda..3efa6aac 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -27,8 +27,8 @@
#include <glib.h> /* GHashTable */
struct _notmuch_message_file {
- /* File object */
- FILE *file;
+ /* open stream to (possibly gzipped) file */
+ GMimeStream *stream;
char *filename;
/* Cache for decoded headers */
@@ -46,9 +46,6 @@ _notmuch_message_file_destructor (notmuch_message_file_t *message)
if (message->message)
g_object_unref (message->message);
- if (message->file)
- fclose (message->file);
-
return 0;
}
@@ -64,15 +61,14 @@ _notmuch_message_file_open_ctx (notmuch_database_t *notmuch,
if (unlikely (message == NULL))
return NULL;
- /* Only needed for error messages during parsing. */
message->filename = talloc_strdup (message, filename);
if (message->filename == NULL)
goto FAIL;
talloc_set_destructor (message, _notmuch_message_file_destructor);
- message->file = fopen (filename, "r");
- if (message->file == NULL)
+ message->stream = g_mime_stream_gzfile_open (filename);
+ if (message->stream == NULL)
goto FAIL;
return message;
@@ -105,17 +101,17 @@ _notmuch_message_file_close (notmuch_message_file_t *message)
}
static bool
-_is_mbox (FILE *file)
+_is_mbox (GMimeStream *stream)
{
char from_buf[5];
bool ret = false;
/* Is this mbox? */
- if (fread (from_buf, sizeof (from_buf), 1, file) == 1 &&
+ if (g_mime_stream_read (stream, from_buf, sizeof (from_buf)) == sizeof(from_buf) &&
strncmp (from_buf, "From ", 5) == 0)
ret = true;
- rewind (file);
+ g_mime_stream_reset (stream);
return ret;
}
@@ -123,7 +119,6 @@ _is_mbox (FILE *file)
notmuch_status_t
_notmuch_message_file_parse (notmuch_message_file_t *message)
{
- GMimeStream *stream;
GMimeParser *parser;
notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
static int initialized = 0;
@@ -132,7 +127,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
if (message->message)
return NOTMUCH_STATUS_SUCCESS;
- is_mbox = _is_mbox (message->file);
+ is_mbox = _is_mbox (message->stream);
if (! initialized) {
g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);
@@ -144,12 +139,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
if (! message->headers)
return NOTMUCH_STATUS_OUT_OF_MEMORY;
- stream = g_mime_stream_file_new (message->file);
-
- /* We'll own and fclose the FILE* ourselves. */
- g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), false);
-
- parser = g_mime_parser_new_with_stream (stream);
+ parser = g_mime_parser_new_with_stream (message->stream);
g_mime_parser_set_scan_from (parser, is_mbox);
message->message = g_mime_parser_construct_message (parser);
@@ -167,7 +157,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
}
DONE:
- g_object_unref (stream);
+ g_mime_stream_reset (message->stream);
g_object_unref (parser);
if (status) {
@@ -179,7 +169,6 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
message->message = NULL;
}
- rewind (message->file);
}
return status;
diff --git a/test/T740-gzip.sh b/test/T740-gzip.sh
new file mode 100755
index 00000000..96464956
--- /dev/null
+++ b/test/T740-gzip.sh
@@ -0,0 +1,115 @@
+#!/usr/bin/env bash
+test_description='support for gzipped messages'
+. $(dirname "$0")/test-lib.sh || exit 1
+
+#######################################################################
+# notmuch new
+test_begin_subtest "Single new gzipped message"
+generate_message
+gzip $gen_msg_filename
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "Added 1 new message to the database."
+
+test_begin_subtest "Single new gzipped message (full-scan)"
+generate_message
+gzip $gen_msg_filename
+output=$(NOTMUCH_NEW --debug --full-scan 2>&1)
+test_expect_equal "$output" "Added 1 new message to the database."
+
+test_begin_subtest "Multiple new messages, one gzipped"
+generate_message
+gzip $gen_msg_filename
+generate_message
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "Added 2 new messages to the database."
+
+test_begin_subtest "Multiple new messages, one gzipped (full-scan)"
+generate_message
+gzip $gen_msg_filename
+generate_message
+output=$(NOTMUCH_NEW --debug --full-scan 2>&1)
+test_expect_equal "$output" "Added 2 new messages to the database."
+
+test_begin_subtest "Renamed (gzipped) message"
+generate_message
+echo $gen_message_filename
+notmuch new > /dev/null
+gzip $gen_msg_filename
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "(D) add_files, pass 2: queuing passed file ${gen_msg_filename} for deletion from database
+No new mail. Detected 1 file rename."
+
+######################################################################
+# notmuch search
+
+test_begin_subtest "notmuch search with partially gzipped mail store"
+notmuch search '*' | notmuch_search_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Single new gzipped message (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Single new gzipped message (full-scan) (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Multiple new messages, one gzipped (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Multiple new messages, one gzipped (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Multiple new messages, one gzipped (full-scan) (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Multiple new messages, one gzipped (full-scan) (inbox unread)
+thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Renamed (gzipped) message (inbox unread)
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "notmuch search --output=files with partially gzipped mail store"
+notmuch search --output=files '*' | notmuch_search_files_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+MAIL_DIR/msg-001.gz
+MAIL_DIR/msg-002.gz
+MAIL_DIR/msg-003.gz
+MAIL_DIR/msg-004
+MAIL_DIR/msg-005.gz
+MAIL_DIR/msg-006
+MAIL_DIR/msg-007.gz
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+######################################################################
+# notmuch show
+
+test_begin_subtest "show un-gzipped message"
+notmuch show id:msg-006@notmuch-test-suite | notmuch_show_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+\fmessage{ id:msg-006@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-006
+\fheader{
+Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox unread)
+Subject: Multiple new messages, one gzipped (full-scan)
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: Notmuch Test Suite <test_suite@notmuchmail.org>
+Date: Fri, 05 Jan 2001 15:43:51 +0000
+\fheader}
+\fbody{
+\fpart{ ID: 1, Content-type: text/plain
+This is just a test message (#6)
+\fpart}
+\fbody}
+\fmessage}
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "show gzipped message"
+test_subtest_known_broken
+notmuch show id:msg-007@notmuch-test-suite | notmuch_show_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+\fmessage{ id:msg-007@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-007.gz
+\fheader{
+Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox unread)
+Subject: Renamed (gzipped) message
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: Notmuch Test Suite <test_suite@notmuchmail.org>
+Date: Fri, 05 Jan 2001 15:43:50 +0000
+\fheader}
+\fbody{
+\fpart{ ID: 1, Content-type: text/plain
+This is just a test message (#7)
+\fpart}
+\fbody}
+\fmessage}
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_done
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] cli/notmuch-show: support gzipped files
2019-03-30 14:06 Support gzipped message file David Bremner
2019-03-30 14:06 ` [PATCH 1/3] util/gmime-extra: add g_mime_stream_gzfile_{new, open} David Bremner
2019-03-30 14:06 ` [PATCH 2/3] lib/message_file: open gzipped files David Bremner
@ 2019-03-30 14:06 ` David Bremner
2019-04-30 17:24 ` Support gzipped message file David Bremner
3 siblings, 0 replies; 7+ messages in thread
From: David Bremner @ 2019-03-30 14:06 UTC (permalink / raw)
To: notmuch
This drops "file" from mime_node_context and just uses a local
variable. It also uses the new gzip aware utility routines recently
added to util/gmime-extra.c. The use of gzopen / gzfile in addition is
a bit icky, but the choice is between that, and providing yet another
readline implimentation that understands GMime streams.
---
mime-node.c | 22 +++++++++---------
notmuch-show.c | 50 +++++++++++++++++++++++------------------
test/T740-gzip.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 95 insertions(+), 34 deletions(-)
diff --git a/mime-node.c b/mime-node.c
index 2a24e537..4170da03 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -21,13 +21,16 @@
* Austin Clements <aclements@csail.mit.edu>
*/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#include "notmuch-client.h"
/* Context that gets inherited from the root node. */
typedef struct mime_node_context {
/* Per-message resources. These are allocated internally and must
* be destroyed. */
- FILE *file;
GMimeStream *stream;
GMimeParser *parser;
GMimeMessage *mime_message;
@@ -48,9 +51,6 @@ _mime_node_context_free (mime_node_context_t *res)
if (res->stream)
g_object_unref (res->stream);
- if (res->file)
- fclose (res->file);
-
return 0;
}
@@ -62,6 +62,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
mime_node_context_t *mctx;
mime_node_t *root;
notmuch_status_t status;
+ int fd;
root = talloc_zero (ctx, mime_node_t);
if (root == NULL) {
@@ -80,8 +81,8 @@ 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) {
+ fd = open (filename, O_RDONLY);
+ if (fd == -1) {
/* 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
@@ -92,13 +93,13 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
notmuch_filenames_move_to_next (filenames))
{
filename = notmuch_filenames_get (filenames);
- mctx->file = fopen (filename, "r");
- if (mctx->file)
+ fd = open (filename, O_RDONLY);
+ if (fd != -1)
break;
}
talloc_free (filenames);
- if (! mctx->file) {
+ if (fd == -1) {
/* Give up */
fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));
status = NOTMUCH_STATUS_FILE_ERROR;
@@ -106,13 +107,12 @@ mime_node_open (const void *ctx, notmuch_message_t *message,
}
}
- mctx->stream = g_mime_stream_file_new (mctx->file);
+ mctx->stream = g_mime_stream_gzfile_new (fd);
if (!mctx->stream) {
fprintf (stderr, "Out of memory.\n");
status = NOTMUCH_STATUS_OUT_OF_MEMORY;
goto DONE;
}
- 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) {
diff --git a/notmuch-show.c b/notmuch-show.c
index 07e9a5db..4b48c64e 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -21,6 +21,7 @@
#include "notmuch-client.h"
#include "gmime-filter-reply.h"
#include "sprinter.h"
+#include "zlib-extra.h"
static const char *
_get_tags_as_string (const void *ctx, notmuch_message_t *message)
@@ -781,7 +782,7 @@ format_part_mbox (const void *ctx, unused (sprinter_t *sp), mime_node_t *node,
notmuch_message_t *message = node->envelope_file;
const char *filename;
- FILE *file;
+ gzFile file;
const char *from;
time_t date;
@@ -789,14 +790,14 @@ format_part_mbox (const void *ctx, unused (sprinter_t *sp), mime_node_t *node,
char date_asctime[26];
char *line = NULL;
- size_t line_size;
+ ssize_t line_size;
ssize_t line_len;
if (!message)
INTERNAL_ERROR ("format_part_mbox requires a root part");
filename = notmuch_message_get_filename (message);
- file = fopen (filename, "r");
+ file = gzopen (filename, "r");
if (file == NULL) {
fprintf (stderr, "Failed to open %s: %s\n",
filename, strerror (errno));
@@ -812,7 +813,7 @@ format_part_mbox (const void *ctx, unused (sprinter_t *sp), mime_node_t *node,
printf ("From %s %s", from, date_asctime);
- while ((line_len = getline (&line, &line_size, file)) != -1 ) {
+ while ((line_len = gz_getline (message, &line, &line_size, file)) != UTIL_EOF ) {
if (_is_from_line (line))
putchar ('>');
printf ("%s", line);
@@ -820,7 +821,7 @@ format_part_mbox (const void *ctx, unused (sprinter_t *sp), mime_node_t *node,
printf ("\n");
- fclose (file);
+ gzclose (file);
return NOTMUCH_STATUS_SUCCESS;
}
@@ -833,39 +834,44 @@ format_part_raw (unused (const void *ctx), unused (sprinter_t *sp),
if (node->envelope_file) {
/* Special case the entire message to avoid MIME parsing. */
const char *filename;
- FILE *file;
- size_t size;
+ GMimeStream *stream = NULL;
+ ssize_t ssize;
char buf[4096];
+ notmuch_status_t ret = NOTMUCH_STATUS_FILE_ERROR;
filename = notmuch_message_get_filename (node->envelope_file);
if (filename == NULL) {
fprintf (stderr, "Error: Cannot get message filename.\n");
- return NOTMUCH_STATUS_FILE_ERROR;
+ goto DONE;
}
- file = fopen (filename, "r");
- if (file == NULL) {
+ stream = g_mime_stream_gzfile_open (filename);
+ if (stream == NULL) {
fprintf (stderr, "Error: Cannot open file %s: %s\n", filename, strerror (errno));
- return NOTMUCH_STATUS_FILE_ERROR;
+ goto DONE;
}
- while (!feof (file)) {
- size = fread (buf, 1, sizeof (buf), file);
- if (ferror (file)) {
+ while (! g_mime_stream_eos (stream)) {
+ ssize = g_mime_stream_read (stream, buf, sizeof(buf));
+ if (ssize < 0) {
fprintf (stderr, "Error: Read failed from %s\n", filename);
- fclose (file);
- return NOTMUCH_STATUS_FILE_ERROR;
+ goto DONE;
}
- if (fwrite (buf, size, 1, stdout) != 1) {
- fprintf (stderr, "Error: Write failed\n");
- fclose (file);
- return NOTMUCH_STATUS_FILE_ERROR;
+ if (ssize > 0 && fwrite (buf, ssize, 1, stdout) != 1) {
+ fprintf (stderr, "Error: Write %ld chars to stdout failed\n", ssize);
+ goto DONE;
}
}
- fclose (file);
- return NOTMUCH_STATUS_SUCCESS;
+ ret = NOTMUCH_STATUS_SUCCESS;
+
+ /* XXX This DONE is just for the special case of a node in a single file */
+ DONE:
+ if (stream)
+ g_object_unref (stream);
+
+ return ret;
}
GMimeStream *stream_filter = g_mime_stream_filter_new (params->out_stream);
diff --git a/test/T740-gzip.sh b/test/T740-gzip.sh
index 96464956..5b678fa1 100755
--- a/test/T740-gzip.sh
+++ b/test/T740-gzip.sh
@@ -91,8 +91,35 @@ This is just a test message (#6)
EOF
test_expect_equal_file EXPECTED OUTPUT
+test_begin_subtest "show un-gzipped message (format mbox)"
+notmuch show --format=mbox id:msg-006@notmuch-test-suite | notmuch_show_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+From test_suite@notmuchmail.org Fri Jan 5 15:43:51 2001
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: Notmuch Test Suite <test_suite@notmuchmail.org>
+Message-Id: <msg-006@notmuch-test-suite>
+Subject: Multiple new messages, one gzipped (full-scan)
+Date: Fri, 05 Jan 2001 15:43:51 +0000
+
+This is just a test message (#6)
+
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "show un-gzipped message (format raw)"
+notmuch show --format=raw id:msg-006@notmuch-test-suite | notmuch_show_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: Notmuch Test Suite <test_suite@notmuchmail.org>
+Message-Id: <msg-006@notmuch-test-suite>
+Subject: Multiple new messages, one gzipped (full-scan)
+Date: Fri, 05 Jan 2001 15:43:51 +0000
+
+This is just a test message (#6)
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
test_begin_subtest "show gzipped message"
-test_subtest_known_broken
notmuch show id:msg-007@notmuch-test-suite | notmuch_show_sanitize > OUTPUT
cat <<EOF > EXPECTED
\fmessage{ id:msg-007@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-007.gz
@@ -112,4 +139,32 @@ This is just a test message (#7)
EOF
test_expect_equal_file EXPECTED OUTPUT
+test_begin_subtest "show gzipped message (mbox)"
+notmuch show --format=mbox id:msg-007@notmuch-test-suite | notmuch_show_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+From test_suite@notmuchmail.org Fri Jan 5 15:43:50 2001
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: Notmuch Test Suite <test_suite@notmuchmail.org>
+Message-Id: <msg-007@notmuch-test-suite>
+Subject: Renamed (gzipped) message
+Date: Fri, 05 Jan 2001 15:43:50 +0000
+
+This is just a test message (#7)
+
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "show gzipped message (raw)"
+notmuch show --format=raw id:msg-007@notmuch-test-suite | notmuch_show_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: Notmuch Test Suite <test_suite@notmuchmail.org>
+Message-Id: <msg-007@notmuch-test-suite>
+Subject: Renamed (gzipped) message
+Date: Fri, 05 Jan 2001 15:43:50 +0000
+
+This is just a test message (#7)
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
test_done
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Support gzipped message file
2019-03-30 14:06 Support gzipped message file David Bremner
` (2 preceding siblings ...)
2019-03-30 14:06 ` [PATCH 3/3] cli/notmuch-show: support " David Bremner
@ 2019-04-30 17:24 ` David Bremner
2019-04-30 17:41 ` David Bremner
2019-05-03 11:02 ` David Bremner
3 siblings, 2 replies; 7+ messages in thread
From: David Bremner @ 2019-04-30 17:24 UTC (permalink / raw)
To: notmuch
[-- Attachment #1: Type: text/plain, Size: 313 bytes --]
David Bremner <david@tethera.net> writes:
> This obsoletes the WIP series id:20190324033244.12909-2-david@tethera.net
>
> Compared to the WIP version, this has some general cleanup, and a
> switch to using an open file descriptor to create a stream rather than
> a FILE*.
I have made two minor changes in git
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: inter.diff --]
[-- Type: text/x-diff, Size: 599 bytes --]
diff --git a/test/T750-gzip.sh b/test/T740-gzip.sh
similarity index 100%
rename from test/T750-gzip.sh
rename to test/T740-gzip.sh
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index e422fec3..b3f91c55 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -26,8 +26,7 @@ _gzfile_maybe_filter (GMimeStream *file_stream) {
if (! gzstream)
return NULL;
- /* ignore filter id */
- (void)g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter);
+ g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter);
return gzstream;
} else {
return file_stream;
[-- Attachment #3: Type: text/plain, Size: 121 bytes --]
If anyone has any other suggestions, please let me know ASAP, otherwise
I may apply the Chomsky rule of code review.
d
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Support gzipped message file
2019-04-30 17:24 ` Support gzipped message file David Bremner
@ 2019-04-30 17:41 ` David Bremner
2019-05-03 11:02 ` David Bremner
1 sibling, 0 replies; 7+ messages in thread
From: David Bremner @ 2019-04-30 17:41 UTC (permalink / raw)
To: notmuch
David Bremner <david@tethera.net> writes:
> David Bremner <david@tethera.net> writes:
>
>> This obsoletes the WIP series id:20190324033244.12909-2-david@tethera.net
>>
>> Compared to the WIP version, this has some general cleanup, and a
>> switch to using an open file descriptor to create a stream rather than
>> a FILE*.
>
> I have made two minor changes in git
>
> diff --git a/test/T750-gzip.sh b/test/T740-gzip.sh
> similarity index 100%
> rename from test/T750-gzip.sh
> rename to test/T740-gzip.sh
> diff --git a/util/gmime-extra.c b/util/gmime-extra.c
> index e422fec3..b3f91c55 100644
> --- a/util/gmime-extra.c
> +++ b/util/gmime-extra.c
> @@ -26,8 +26,7 @@ _gzfile_maybe_filter (GMimeStream *file_stream) {
> if (! gzstream)
> return NULL;
>
> - /* ignore filter id */
> - (void)g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter);
> + g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter);
> return gzstream;
> } else {
> return file_stream;
That's a reversed diff, of course.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Support gzipped message file
2019-04-30 17:24 ` Support gzipped message file David Bremner
2019-04-30 17:41 ` David Bremner
@ 2019-05-03 11:02 ` David Bremner
1 sibling, 0 replies; 7+ messages in thread
From: David Bremner @ 2019-05-03 11:02 UTC (permalink / raw)
To: notmuch
David Bremner <david@tethera.net> writes:
>
> If anyone has any other suggestions, please let me know ASAP, otherwise
> I may apply the Chomsky rule of code review.
Hmm. I might have misattributed the quote about silence and consent to
Chomsky. Anyway I pushed the series.
d
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-05-03 11:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-30 14:06 Support gzipped message file David Bremner
2019-03-30 14:06 ` [PATCH 1/3] util/gmime-extra: add g_mime_stream_gzfile_{new, open} David Bremner
2019-03-30 14:06 ` [PATCH 2/3] lib/message_file: open gzipped files David Bremner
2019-03-30 14:06 ` [PATCH 3/3] cli/notmuch-show: support " David Bremner
2019-04-30 17:24 ` Support gzipped message file David Bremner
2019-04-30 17:41 ` David Bremner
2019-05-03 11:02 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).