1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 4C743431FAF
\r
6 for <notmuch@notmuchmail.org>; Thu, 3 Apr 2014 19:44:15 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id ofKy6FAUZxIL for <notmuch@notmuchmail.org>;
\r
16 Thu, 3 Apr 2014 19:44:10 -0700 (PDT)
\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net
\r
18 [87.98.215.224]) (using TLSv1 with cipher AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 0DCEC431FD4
\r
21 for <notmuch@notmuchmail.org>; Thu, 3 Apr 2014 19:44:00 -0700 (PDT)
\r
22 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim
\r
23 4.72) (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
25 for notmuch@notmuchmail.org; Fri, 04 Apr 2014 02:08:26 +0000
\r
26 Received: (nullmailer pid 4009 invoked by uid 1000); Thu, 03 Apr 2014
\r
28 From: David Bremner <david@tethera.net>
\r
29 To: notmuch@notmuchmail.org
\r
30 Subject: v6 gzipped dump/restore
\r
31 Date: Thu, 3 Apr 2014 16:41:17 -0300
\r
32 Message-Id: <1396554083-3892-1-git-send-email-david@tethera.net>
\r
33 X-Mailer: git-send-email 1.9.0
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.13
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Fri, 04 Apr 2014 02:44:15 -0000
\r
48 I hope I got all the comments from Tomi and Austin. Interdiff below.
\r
50 I ended up collapsing two patches while I was revising, since it
\r
51 seemed artificial to do some of the changes twice to keep the gzipped
\r
52 and atomic features as seperate patches.
\r
55 diff --git a/INSTALL b/INSTALL
\r
56 index df318fa..b543c50 100644
\r
59 @@ -67,6 +67,9 @@ Talloc, and zlib which are each described below:
\r
60 by Xapian, so if you installed that you will already have
\r
61 zlib. You may need to install the zlib headers separately.
\r
63 + Notmuch needs the transparent write feature of zlib introduced
\r
64 + in version 1.2.5.2 (Dec. 2011).
\r
66 zlib is available from http://zlib.net
\r
68 Building Documentation
\r
69 diff --git a/configure b/configure
\r
70 index d685ab3..1d624f7 100755
\r
73 @@ -340,9 +340,9 @@ else
\r
74 errors=$((errors + 1))
\r
77 -printf "Checking for zlib development files... "
\r
78 +printf "Checking for zlib (>= 1.2.5.2)... "
\r
80 -if pkg-config --exists zlib; then
\r
81 +if pkg-config --atleast-version=1.2.5.2 zlib; then
\r
84 zlib_cflags=$(pkg-config --cflags zlib)
\r
85 diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
86 index 05ed6b4..2a7252a 100644
\r
87 --- a/notmuch-dump.c
\r
88 +++ b/notmuch-dump.c
\r
89 @@ -140,7 +140,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
\r
90 tempname = talloc_asprintf (notmuch, "%s.XXXXXX", output_file_name);
\r
91 outfd = mkstemp (tempname);
\r
93 - outfd = fileno (stdout);
\r
94 + outfd = dup (STDOUT_FILENO);
\r
98 @@ -153,6 +153,9 @@ notmuch_database_dump (notmuch_database_t *notmuch,
\r
99 if (output == NULL) {
\r
100 fprintf (stderr, "Error opening %s for (gzip) writing: %s\n",
\r
101 name_for_error, strerror (errno));
\r
102 + if (close (outfd))
\r
103 + fprintf (stderr, "Error closing %s during shutdown: %s\n",
\r
104 + name_for_error, strerror (errno));
\r
108 @@ -165,22 +168,25 @@ notmuch_database_dump (notmuch_database_t *notmuch,
\r
112 - ret = fdatasync (outfd);
\r
114 - perror ("fdatasync");
\r
118 if (output_file_name) {
\r
119 - ret = gzclose_w (output);
\r
120 - if (ret != Z_OK) {
\r
121 - ret = EXIT_FAILURE;
\r
122 + ret = fdatasync (outfd);
\r
124 + fprintf (stderr, "Error syncing %s to disk: %s\n",
\r
125 + name_for_error, strerror (errno));
\r
130 + if (gzclose_w (output) != Z_OK) {
\r
131 + ret = EXIT_FAILURE;
\r
135 + if (output_file_name) {
\r
136 ret = rename (tempname, output_file_name);
\r
138 - perror ("rename");
\r
139 + fprintf (stderr, "Error renaming %s to %s: %s\n",
\r
140 + tempname, output_file_name, strerror (errno));
\r
144 diff --git a/notmuch-new.c b/notmuch-new.c
\r
145 index e0431c6..d269c7c 100644
\r
146 --- a/notmuch-new.c
\r
147 +++ b/notmuch-new.c
\r
148 @@ -997,7 +997,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
149 * relatively small. */
\r
151 const char *backup_name =
\r
152 - talloc_asprintf (notmuch, "%s/backup-%04d-%02d-%02d-%02d:%02d:%02d.gz",
\r
153 + talloc_asprintf (notmuch, "%s/dump-%04d%02d%02dT%02d%02d%02d.gz",
\r
155 gm_time->tm_year + 1900,
\r
156 gm_time->tm_mon + 1,
\r
157 @@ -1009,12 +1009,12 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
158 if (add_files_state.verbosity >= VERBOSITY_NORMAL) {
\r
159 printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n");
\r
160 printf ("This process is safe to interrupt.\n");
\r
161 - printf ("Backing up tags to %s\n", backup_name);
\r
162 + printf ("Backing up tags to %s...\n", backup_name);
\r
165 if (notmuch_database_dump (notmuch, backup_name, "",
\r
166 DUMP_FORMAT_BATCH_TAG, TRUE)) {
\r
167 - fprintf (stderr, "Backup failed. Aborting upgrade");
\r
168 + fprintf (stderr, "Backup failed. Aborting upgrade.");
\r
169 return EXIT_FAILURE;
\r
172 diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
173 index 86bce20..eb5b7b2 100644
\r
174 --- a/notmuch-restore.c
\r
175 +++ b/notmuch-restore.c
\r
176 @@ -132,7 +132,6 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
\r
179 void *line_ctx = NULL;
\r
180 - size_t line_size;
\r
184 @@ -166,8 +165,16 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
\r
186 if (input_file_name)
\r
187 input = gzopen (input_file_name, "r");
\r
189 - input = gzdopen (fileno (stdin), "r");
\r
191 + int infd = dup (STDIN_FILENO);
\r
193 + fprintf (stderr, "Error duping stdin\n");
\r
194 + return EXIT_FAILURE;
\r
196 + input = gzdopen (infd, "r");
\r
201 if (input == NULL) {
\r
202 fprintf (stderr, "Error opening %s for (gzip) reading: %s\n",
\r
203 @@ -189,7 +196,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
\r
205 util_status_t status;
\r
207 - status = gz_getline (line_ctx, &line, &line_size, &line_len, input);
\r
208 + status = gz_getline (line_ctx, &line, &line_len, input);
\r
210 /* empty input file not considered an error */
\r
211 if (status == UTIL_EOF)
\r
212 @@ -262,7 +269,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
\r
216 - } while (gz_getline (line_ctx, &line, &line_size, &line_len, input) == UTIL_SUCCESS);
\r
217 + } while (gz_getline (line_ctx, &line, &line_len, input) == UTIL_SUCCESS);
\r
219 if (line_ctx != NULL)
\r
220 talloc_free (line_ctx);
\r
221 @@ -272,8 +279,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])
\r
223 notmuch_database_destroy (notmuch);
\r
225 - if (input_file_name != NULL)
\r
226 - gzclose_r (input);
\r
227 + gzclose_r (input);
\r
229 return ret ? EXIT_FAILURE : EXIT_SUCCESS;
\r
231 diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh
\r
232 index 50d4d48..efe463e 100755
\r
233 --- a/test/T240-dump-restore.sh
\r
234 +++ b/test/T240-dump-restore.sh
\r
235 @@ -124,6 +124,15 @@ notmuch dump --format=batch-tag from:cworth | sed 's/^.*-- id://' | \
\r
236 sort > OUTPUT.$test_count
\r
237 test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
\r
239 +test_begin_subtest "format=batch-tag, missing newline"
\r
240 +printf "+a_tag_without_newline -- id:20091117232137.GA7669@griffis1.net" > IN
\r
241 +notmuch restore --accumulate < IN
\r
242 +notmuch dump id:20091117232137.GA7669@griffis1.net > OUT
\r
243 +cat <<EOF > EXPECTED
\r
244 ++a_tag_without_newline +inbox +unread -- id:20091117232137.GA7669@griffis1.net
\r
246 +test_expect_equal_file EXPECTED OUT
\r
248 test_begin_subtest "format=batch-tag, # round-trip"
\r
249 notmuch dump --format=sup | sort > EXPECTED.$test_count
\r
250 notmuch dump --format=batch-tag | notmuch restore --format=batch-tag
\r
251 diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
\r
252 index 7a68ddf..7d5d5aa 100755
\r
253 --- a/test/T530-upgrade.sh
\r
254 +++ b/test/T530-upgrade.sh
\r
255 @@ -37,7 +37,7 @@ Your notmuch database has now been upgraded to database format version 2.
\r
258 test_begin_subtest "tag backup matches pre-upgrade dump"
\r
259 -gunzip -c ${MAIL_DIR}/.notmuch/backup-*.gz | sort > backup-dump
\r
260 +gunzip -c ${MAIL_DIR}/.notmuch/dump-*.gz | sort > backup-dump
\r
261 test_expect_equal_file pre-upgrade-dump backup-dump
\r
263 test_begin_subtest "folder: no longer matches in the middle of path"
\r
264 diff --git a/util/zlib-extra.c b/util/zlib-extra.c
\r
265 index cb1eba0..922ab52 100644
\r
266 --- a/util/zlib-extra.c
\r
267 +++ b/util/zlib-extra.c
\r
268 @@ -25,34 +25,36 @@
\r
270 /* mimic POSIX/glibc getline, but on a zlib gzFile stream, and using talloc */
\r
272 -gz_getline (void *talloc_ctx, char **bufptr, size_t *bufsiz, ssize_t *bytes_read,
\r
274 +gz_getline (void *talloc_ctx, char **bufptr, ssize_t *bytes_read, gzFile stream)
\r
276 - size_t len = *bufsiz;
\r
277 char *buf = *bufptr;
\r
278 + unsigned int len;
\r
281 - if (len == 0 || buf == NULL) {
\r
283 + len = talloc_array_length (buf);
\r
285 /* same as getdelim from gnulib */
\r
287 - buf = talloc_size (talloc_ctx, len);
\r
288 + buf = talloc_array (talloc_ctx, char, len);
\r
290 return UTIL_OUT_OF_MEMORY;
\r
294 if (! gzgets (stream, buf + offset, len - offset)) {
\r
295 + /* Null indicates EOF or error */
\r
296 int zlib_status = 0;
\r
297 (void) gzerror (stream, &zlib_status);
\r
298 switch (zlib_status) {
\r
300 - /* follow getline behaviour */
\r
301 - *bytes_read = -1;
\r
304 + /* no data read before EOF */
\r
315 @@ -60,17 +62,16 @@ gz_getline (void *talloc_ctx, char **bufptr, size_t *bufsiz, ssize_t *bytes_read
\r
317 offset += strlen (buf + offset);
\r
319 - if ( buf[offset - 1] == '\n' )
\r
321 + if (buf[offset - 1] == '\n')
\r
325 buf = talloc_realloc (talloc_ctx, buf, char, len);
\r
327 return UTIL_OUT_OF_MEMORY;
\r
333 *bytes_read = offset;
\r
334 return UTIL_SUCCESS;
\r
336 diff --git a/util/zlib-extra.h b/util/zlib-extra.h
\r
337 index ed46ac1..ed67115 100644
\r
338 --- a/util/zlib-extra.h
\r
339 +++ b/util/zlib-extra.h
\r
341 #ifndef _ZLIB_EXTRA_H
\r
342 #define _ZLIB_EXTRA_H
\r
348 /* Like getline, but read from a gzFile. Allocation is with talloc */
\r
350 -gz_getline (void *ctx, char **lineptr, size_t *line_size, ssize_t *bytes_read,
\r
352 +gz_getline (void *ctx, char **lineptr, ssize_t *bytes_read, gzFile stream);
\r