Re: [PATCH v2] test: check the handling of files vanishing between scandir and indexing

2016-11-28 Thread Tomi Ollila
On Tue, Nov 29 2016, David Bremner  wrote:

> Jani Nikula  writes:
>
>> +gdb --batch-silent --return-child-result -x notmuch-new-vanish.gdb \
>> +--args notmuch new 2>OUTPUT 1>/dev/null
>
> I wonder if Tomi's suggestion of
>
>   id:20161128221231.25528-2-da...@tethera.net
>
> applies here as well. In this case it is redirecting output, rather than
> input, but I guess the same principle applies?

In case of input it may matter who has chance to consume it. In this
case of output every output of every process is dumped to /dev/null; I'd go
with this simpler approach in this case (and probably in all other cases;
If we wanted to (debug) log things we used `--batch` and redirecs to log
files instead of /dev/null).

Tomi


>
> d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Trouble decrypting multipart/encrypted

2016-11-28 Thread Eric Skoglund
David Bremner  writes:

>
> Yeah, --verify only works with one of the structured output formats
> (json or sexp). I suppose that's probably a documentation bug.
>
> try
>
> % notmuch show --format=json --verify $message

Yes that did work, getting "sigstatus : [ { 'status': 'good'  }]".

// Eric
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] test: check the handling of files vanishing between scandir and indexing

2016-11-28 Thread David Bremner
Jani Nikula  writes:

> +gdb --batch-silent --return-child-result -x notmuch-new-vanish.gdb \
> +--args notmuch new 2>OUTPUT 1>/dev/null

I wonder if Tomi's suggestion of

  id:20161128221231.25528-2-da...@tethera.net

applies here as well. In this case it is redirecting output, rather than
input, but I guess the same principle applies?

d

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v3] build: update the desktop database after installing the desktop file

2016-11-28 Thread David Bremner
Jani Nikula  writes:

> This makes the option to choose Notmuch as mailto: handler show up in
> the desktop environment settings. Ignore errors.

pushed to master.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v3] build: install notmuch-emacs-mua.desktop file with emacs

2016-11-28 Thread David Bremner
Jani Nikula  writes:

> There is really no need to have a separate install target for the
> desktop file. Just install the desktop file with emacs, with a
> configure option to opt out.
>
> ---
>
> v3: check for desktop-file-install in configure.
>

pushed to master.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] doc: whitespace cleanup

2016-11-28 Thread David Bremner
Tomi Ollila  writes:

> In most part, our .rst documents are indented with 8 spaces instead
> of tabs. Bring the rest of the lines to the same format.
> Also, on one (supposedly empty) line, trailing spaces were removed.

pushed to master

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/3] test: gdb insert: redirect input inside gdb script

2016-11-28 Thread David Bremner
From: Tomi Ollila 

Running `gdb command < input` is not as reliable way to give input
to the command (some installations of gdb consume it). Use "set args"
gdb command to have input redirected at gdb 'run' time.
---
 test/T070-insert.sh | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index c2485bb..43b3abc 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -202,13 +202,15 @@ end
 run
 EOF
 test_begin_subtest "error exit when add_message returns $code"
-gdb --batch-silent --return-child-result -x index-file-$code.gdb \
---args notmuch insert  < $gen_msg_filename
+gdb --batch-silent --return-child-result \
+-ex "set args insert < $gen_msg_filename" \
+-x index-file-$code.gdb notmuch
 test_expect_equal $? 1
 
 test_begin_subtest "success exit with --keep when add_message returns $code"
-gdb --batch-silent --return-child-result -x index-file-$code.gdb \
---args notmuch insert --keep  < $gen_msg_filename
+gdb --batch-silent --return-child-result \
+-ex "set args insert --keep < $gen_msg_filename" \
+-x index-file-$code.gdb notmuch
 test_expect_equal $? 0
 done
 
-- 
2.10.2

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 3/3] cli/insert: return EX_TEMPFAIL for some errors

2016-11-28 Thread David Bremner
Attempt to distinguish between errors indicating misconfiguration or
programmer error, which we consider "permanent", in the sense that
automatic retries are unlikely to be useful, and those indicating
transient error conditions. We consider XAPIAN_EXCEPTION transient
because it covers the important special case of locking failure.
---
 notmuch-client.h|  3 +++
 notmuch-insert.c|  9 +
 status.c| 16 
 test/T070-insert.sh | 36 
 4 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 793f32e..d026e60 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -489,6 +489,9 @@ print_status_database (const char *loc,
   const notmuch_database_t *database,
   notmuch_status_t status);
 
+int
+status_to_exit (notmuch_status_t status);
+
 #include "command-line-arguments.h"
 
 extern char *notmuch_requested_db_uuid;
diff --git a/notmuch-insert.c b/notmuch-insert.c
index 862da88..bc96af0 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -538,9 +538,10 @@ notmuch_insert_command (notmuch_config_t *config, int 
argc, char *argv[])
return EXIT_FAILURE;
 }
 
-   if (notmuch_database_open (notmuch_config_get_database_path (config),
-  NOTMUCH_DATABASE_MODE_READ_WRITE, ))
-   return EXIT_FAILURE;
+status = notmuch_database_open (notmuch_config_get_database_path (config),
+   NOTMUCH_DATABASE_MODE_READ_WRITE, );
+if (status)
+   return keep ? NOTMUCH_STATUS_SUCCESS : status_to_exit (status);
 
 notmuch_exit_if_unmatched_db_uuid (notmuch);
 
@@ -577,5 +578,5 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
notmuch_run_hook (db_path, "post-insert");
 }
 
-return status ? EXIT_FAILURE : EXIT_SUCCESS;
+return status_to_exit (status);
 }
diff --git a/status.c b/status.c
index 45d3fb4..8bc2fe4 100644
--- a/status.c
+++ b/status.c
@@ -36,3 +36,19 @@ print_status_database (const char *loc,
 }
 return status;
 }
+
+int
+status_to_exit (notmuch_status_t status)
+{
+switch (status) {
+case NOTMUCH_STATUS_SUCCESS:
+   return EXIT_SUCCESS;
+case NOTMUCH_STATUS_OUT_OF_MEMORY:
+case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
+case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
+case NOTMUCH_STATUS_FILE_ERROR:
+   return EX_TEMPFAIL;
+default:
+   return EXIT_FAILURE;
+}
+}
diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index 43b3abc..3e7d582 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -189,7 +189,6 @@ notmuch config set new.tags $OLDCONFIG
 
 for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \
 READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
-gen_insert_msg
 cat < index-file-$code.gdb
 set breakpoint pending on
 set logging file index-file-$code.log
@@ -201,17 +200,30 @@ continue
 end
 run
 EOF
-test_begin_subtest "error exit when add_message returns $code"
-gdb --batch-silent --return-child-result \
--ex "set args insert < $gen_msg_filename" \
--x index-file-$code.gdb notmuch
-test_expect_equal $? 1
-
-test_begin_subtest "success exit with --keep when add_message returns $code"
-gdb --batch-silent --return-child-result \
--ex "set args insert --keep < $gen_msg_filename" \
--x index-file-$code.gdb notmuch
-test_expect_equal $? 0
+done
+
+gen_insert_msg
+
+for code in  FILE_NOT_EMAIL READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
+test_expect_code 1 "EXIT_FAILURE when add_message returns $code" \
+ "gdb --batch-silent --return-child-result \
+-ex \"set args insert < $gen_msg_filename\" \
+-x index-file-$code.gdb notmuch"
+test_expect_code 0 "success exit with --keep when add_message returns 
$code" \
+ "gdb --batch-silent --return-child-result \
+-ex \"set args insert --keep < $gen_msg_filename\" \
+-x index-file-$code.gdb notmuch"
+done
+
+for code in OUT_OF_MEMORY XAPIAN_EXCEPTION ; do
+test_expect_code 75 "EX_TEMPFAIL when add_message returns $code" \
+ "gdb --batch-silent --return-child-result \
+-ex \"set args insert < $gen_msg_filename\" \
+-x index-file-$code.gdb notmuch"
+test_expect_code 0 "success exit with --keep when add_message returns 
$code" \
+ "gdb --batch-silent --return-child-result \
+-ex \"set args insert --keep < $gen_msg_filename\" \
+-x index-file-$code.gdb notmuch"
 done
 
 test_done
-- 
2.10.2

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/3] cli/insert: delay database open until after writing mail file

2016-11-28 Thread David Bremner
The idea is to get the mail written to disk, even if we can't open the
database (e.g. because some other process has a write lock, and notmuch
is compiled for non-blocking opens).
---
 notmuch-insert.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/notmuch-insert.c b/notmuch-insert.c
index 131f09e..862da88 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -532,19 +532,19 @@ notmuch_insert_command (notmuch_config_t *config, int 
argc, char *argv[])
 action.sa_flags = 0;
 sigaction (SIGINT, , NULL);
 
-if (notmuch_database_open (notmuch_config_get_database_path (config),
-  NOTMUCH_DATABASE_MODE_READ_WRITE, ))
-   return EXIT_FAILURE;
-
-notmuch_exit_if_unmatched_db_uuid (notmuch);
-
 /* Write the message to the Maildir new directory. */
 newpath = maildir_write_new (config, STDIN_FILENO, maildir);
 if (! newpath) {
-   notmuch_database_destroy (notmuch);
return EXIT_FAILURE;
 }
 
+   if (notmuch_database_open (notmuch_config_get_database_path (config),
+  NOTMUCH_DATABASE_MODE_READ_WRITE, ))
+   return EXIT_FAILURE;
+
+notmuch_exit_if_unmatched_db_uuid (notmuch);
+
+
 /* Index the message. */
 status = add_file (notmuch, newpath, tag_ops, synchronize_flags, keep);
 
-- 
2.10.2

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


v2 of insert tempfail series

2016-11-28 Thread David Bremner
This incorporates Tomi's patch of 

 id:1480367228-22183-1-git-send-email-tomi.oll...@iki.fi

verbatim, to sort out conflicts.

It fixes the issues I alread sent mail about, and puts back the --keep
tests for various error codes.

The interdiff follows; most of it is Tomi's fault :).

diff --git a/notmuch-insert.c b/notmuch-insert.c
index a152f15..bc96af0 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -541,7 +541,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
 status = notmuch_database_open (notmuch_config_get_database_path (config),
NOTMUCH_DATABASE_MODE_READ_WRITE, );
 if (status)
-   return status_to_exit(status);
+   return keep ? NOTMUCH_STATUS_SUCCESS : status_to_exit (status);
 
 notmuch_exit_if_unmatched_db_uuid (notmuch);
 
@@ -578,5 +578,5 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
notmuch_run_hook (db_path, "post-insert");
 }
 
-return status ? status_to_exit(status) : EXIT_SUCCESS;
+return status_to_exit (status);
 }
diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index fd620e5..3e7d582 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -206,14 +206,24 @@ gen_insert_msg
 
 for code in  FILE_NOT_EMAIL READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
 test_expect_code 1 "EXIT_FAILURE when add_message returns $code" \
-   "gdb --batch-silent --return-child-result -x index-file-$code.gdb \
---args notmuch insert  < $gen_msg_filename"
+ "gdb --batch-silent --return-child-result \
+-ex \"set args insert < $gen_msg_filename\" \
+-x index-file-$code.gdb notmuch"
+test_expect_code 0 "success exit with --keep when add_message returns 
$code" \
+ "gdb --batch-silent --return-child-result \
+-ex \"set args insert --keep < $gen_msg_filename\" \
+-x index-file-$code.gdb notmuch"
 done
 
 for code in OUT_OF_MEMORY XAPIAN_EXCEPTION ; do
 test_expect_code 75 "EX_TEMPFAIL when add_message returns $code" \
-   "gdb --batch-silent --return-child-result -x index-file-$code.gdb \
---args notmuch insert  < $gen_msg_filename"
+ "gdb --batch-silent --return-child-result \
+-ex \"set args insert < $gen_msg_filename\" \
+-x index-file-$code.gdb notmuch"
+test_expect_code 0 "success exit with --keep when add_message returns 
$code" \
+ "gdb --batch-silent --return-child-result \
+-ex \"set args insert --keep < $gen_msg_filename\" \
+-x index-file-$code.gdb notmuch"
 done
 
 test_done
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: gdb insert: redirect input inside gdb script

2016-11-28 Thread Tomi Ollila
Running `gdb command < input` is not as reliable way to give input
to the command (some installations of gdb consume it). Use "set args"
gdb command to have input redirected at gdb 'run' time.
---

With this change, these tests work on FreeBSD-11.0-RELEASE-amd64[.qcow2]
when adding gdb 7.11.1 using pkg install (and having /usr/local/bin in
front of path) -- before this gdb just hang -- and it took a while...

On Linux this test keeps working.

After commit and before amend(*) I dropped '-nx' command line option
(to not read any gdbinit files). Perhaps all gdb invocations should
have that (currently none has).

(*) git commit -a --amend -C HEAD ;: let the virus spread :)


 test/T070-insert.sh | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index c2485bb..43b3abc 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -202,13 +202,15 @@ end
 run
 EOF
 test_begin_subtest "error exit when add_message returns $code"
-gdb --batch-silent --return-child-result -x index-file-$code.gdb \
---args notmuch insert  < $gen_msg_filename
+gdb --batch-silent --return-child-result \
+-ex "set args insert < $gen_msg_filename" \
+-x index-file-$code.gdb notmuch
 test_expect_equal $? 1
 
 test_begin_subtest "success exit with --keep when add_message returns $code"
-gdb --batch-silent --return-child-result -x index-file-$code.gdb \
---args notmuch insert --keep  < $gen_msg_filename
+gdb --batch-silent --return-child-result \
+-ex "set args insert --keep < $gen_msg_filename" \
+-x index-file-$code.gdb notmuch
 test_expect_equal $? 0
 done
 
-- 
2.10.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Trouble decrypting multipart/encrypted

2016-11-28 Thread David Bremner
Eric Skoglund  writes:

>>>
>>> Signing and encrypting email via C-c C-m s p and C-c C-m c p works
>>> fine. And given that it doesn't work outside of emacs I don't think it
>>> is an emacs problem. I'm also able to decrypt the message via the
>>> command line using just gpg.
>>
>> Can you verify signed, non-encrypted messages (notmuch show --verify) ?
>>
>
> I'm not getting any output besides the message when I do --verify (same as
> with an unsigned message) so to me it doesn't seem like it is working
> per the man page. But I might be wrong here.
>

Yeah, --verify only works with one of the structured output formats
(json or sexp). I suppose that's probably a documentation bug.

try

% notmuch show --format=json --verify $message

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Trouble decrypting multipart/encrypted

2016-11-28 Thread Eric Skoglund
David Bremner  writes:

> Eric Skoglund  writes:
>
>> Hello, I've recently started using notmuch (together with emacs) and
>> have now encountered some problems when trying to decrypt a
>> multipart/encrypted message.
>
> Is it just this one message, or all multipart/encrypted messages?
>

I've now tried two other encrypted messages and they also fail to
decrypt. epa-mail-decrypt works here so it seems like a notmuch issue,
guessing that there is some configuration that is wrong somewhere.

>>
>> Signing and encrypting email via C-c C-m s p and C-c C-m c p works
>> fine. And given that it doesn't work outside of emacs I don't think it
>> is an emacs problem. I'm also able to decrypt the message via the
>> command line using just gpg.
>
> Can you verify signed, non-encrypted messages (notmuch show --verify) ?
>

I'm not getting any output besides the message when I do --verify (same as
with an unsigned message) so to me it doesn't seem like it is working
per the man page. But I might be wrong here.

// Eric
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/2] cli/insert: delay database open until after writing mail file

2016-11-28 Thread David Bremner
David Bremner  writes:

> The idea is to get the mail written to disk, even if we can't open the
> database (e.g. because some other process has a write lock, and notmuch
> is compiled for non-blocking opens).
> ---
>  notmuch-insert.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/notmuch-insert.c b/notmuch-insert.c
> index 131f09e..862da88 100644
> --- a/notmuch-insert.c
> +++ b/notmuch-insert.c
> @@ -532,19 +532,19 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>  action.sa_flags = 0;
>  sigaction (SIGINT, , NULL);
>  
> -if (notmuch_database_open (notmuch_config_get_database_path (config),
> -NOTMUCH_DATABASE_MODE_READ_WRITE, ))
> - return EXIT_FAILURE;
> -
> -notmuch_exit_if_unmatched_db_uuid (notmuch);
> -
>  /* Write the message to the Maildir new directory. */
>  newpath = maildir_write_new (config, STDIN_FILENO, maildir);
>  if (! newpath) {
> - notmuch_database_destroy (notmuch);
>   return EXIT_FAILURE;
>  }
>  
> +   if (notmuch_database_open (notmuch_config_get_database_path (config),
> +NOTMUCH_DATABASE_MODE_READ_WRITE, ))
> + return EXIT_FAILURE;
> +
> +notmuch_exit_if_unmatched_db_uuid (notmuch);
> +
> +

One extra newline here.

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] cli/insert: return EX_TEMPFAIL for some errors

2016-11-28 Thread David Bremner
David Bremner  writes:

> Attempt to distinguish between errors indicating misconfiguration or
> programmer error, which we consider "permanant", in the sense that
> automatic retries are unlikely to be useful, and those indicating
> transient error conditions. We consider XAPIAN_EXCEPTION transient
> because it covers the important special case of locking failure.
> ---
>  notmuch-client.h|  3 +++
>  notmuch-insert.c|  9 +
>  status.c| 16 
>  test/T070-insert.sh | 24 ++--
>  4 files changed, 38 insertions(+), 14 deletions(-)
>
> diff --git a/notmuch-client.h b/notmuch-client.h
> index 793f32e..d026e60 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -489,6 +489,9 @@ print_status_database (const char *loc,
>  const notmuch_database_t *database,
>  notmuch_status_t status);
>  
> +int
> +status_to_exit (notmuch_status_t status);
> +
>  #include "command-line-arguments.h"
>  
>  extern char *notmuch_requested_db_uuid;
> diff --git a/notmuch-insert.c b/notmuch-insert.c
> index 862da88..a152f15 100644
> --- a/notmuch-insert.c
> +++ b/notmuch-insert.c
> @@ -538,9 +538,10 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>   return EXIT_FAILURE;
>  }
>  
> -   if (notmuch_database_open (notmuch_config_get_database_path (config),
> -NOTMUCH_DATABASE_MODE_READ_WRITE, ))
> - return EXIT_FAILURE;
> +status = notmuch_database_open (notmuch_config_get_database_path 
> (config),
> + NOTMUCH_DATABASE_MODE_READ_WRITE, );
> +if (status)
> + return status_to_exit(status);

I guess this should return NOTMUCH_STATUS_SUCCESS if --keep is passed.

>  notmuch_exit_if_unmatched_db_uuid (notmuch);
>  
> @@ -577,5 +578,5 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>   notmuch_run_hook (db_path, "post-insert");
>  }
>  
> -return status ? EXIT_FAILURE : EXIT_SUCCESS;
> +return status ? status_to_exit(status) : EXIT_SUCCESS;

This can be simplified to just "return status_to_exit (status)".

And whitespace fixes for both calls to status_to_exit.


> +int
> +status_to_exit (notmuch_status_t status)
> +{
> +switch (status) {
> +case NOTMUCH_STATUS_SUCCESS:
> + return EXIT_SUCCESS;
> +case NOTMUCH_STATUS_OUT_OF_MEMORY:
> +case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
> +case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
> +case NOTMUCH_STATUS_FILE_ERROR:
> + return EX_TEMPFAIL;
> +default:
> + return EXIT_FAILURE;
> +}

This classification is pretty arbitrary. The main goal is have locking
errors, which are currently NOTMUCH_STATUS_XAPIAN_EXCEPTION treated as
TEMPFAIL.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] cli/insert: return EX_TEMPFAIL for some errors

2016-11-28 Thread David Bremner
Attempt to distinguish between errors indicating misconfiguration or
programmer error, which we consider "permanant", in the sense that
automatic retries are unlikely to be useful, and those indicating
transient error conditions. We consider XAPIAN_EXCEPTION transient
because it covers the important special case of locking failure.
---
 notmuch-client.h|  3 +++
 notmuch-insert.c|  9 +
 status.c| 16 
 test/T070-insert.sh | 24 ++--
 4 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 793f32e..d026e60 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -489,6 +489,9 @@ print_status_database (const char *loc,
   const notmuch_database_t *database,
   notmuch_status_t status);
 
+int
+status_to_exit (notmuch_status_t status);
+
 #include "command-line-arguments.h"
 
 extern char *notmuch_requested_db_uuid;
diff --git a/notmuch-insert.c b/notmuch-insert.c
index 862da88..a152f15 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -538,9 +538,10 @@ notmuch_insert_command (notmuch_config_t *config, int 
argc, char *argv[])
return EXIT_FAILURE;
 }
 
-   if (notmuch_database_open (notmuch_config_get_database_path (config),
-  NOTMUCH_DATABASE_MODE_READ_WRITE, ))
-   return EXIT_FAILURE;
+status = notmuch_database_open (notmuch_config_get_database_path (config),
+   NOTMUCH_DATABASE_MODE_READ_WRITE, );
+if (status)
+   return status_to_exit(status);
 
 notmuch_exit_if_unmatched_db_uuid (notmuch);
 
@@ -577,5 +578,5 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
notmuch_run_hook (db_path, "post-insert");
 }
 
-return status ? EXIT_FAILURE : EXIT_SUCCESS;
+return status ? status_to_exit(status) : EXIT_SUCCESS;
 }
diff --git a/status.c b/status.c
index 45d3fb4..8bc2fe4 100644
--- a/status.c
+++ b/status.c
@@ -36,3 +36,19 @@ print_status_database (const char *loc,
 }
 return status;
 }
+
+int
+status_to_exit (notmuch_status_t status)
+{
+switch (status) {
+case NOTMUCH_STATUS_SUCCESS:
+   return EXIT_SUCCESS;
+case NOTMUCH_STATUS_OUT_OF_MEMORY:
+case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
+case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
+case NOTMUCH_STATUS_FILE_ERROR:
+   return EX_TEMPFAIL;
+default:
+   return EXIT_FAILURE;
+}
+}
diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index c2485bb..fd620e5 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -189,7 +189,6 @@ notmuch config set new.tags $OLDCONFIG
 
 for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \
 READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
-gen_insert_msg
 cat < index-file-$code.gdb
 set breakpoint pending on
 set logging file index-file-$code.log
@@ -201,15 +200,20 @@ continue
 end
 run
 EOF
-test_begin_subtest "error exit when add_message returns $code"
-gdb --batch-silent --return-child-result -x index-file-$code.gdb \
---args notmuch insert  < $gen_msg_filename
-test_expect_equal $? 1
-
-test_begin_subtest "success exit with --keep when add_message returns $code"
-gdb --batch-silent --return-child-result -x index-file-$code.gdb \
---args notmuch insert --keep  < $gen_msg_filename
-test_expect_equal $? 0
+done
+
+gen_insert_msg
+
+for code in  FILE_NOT_EMAIL READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do
+test_expect_code 1 "EXIT_FAILURE when add_message returns $code" \
+   "gdb --batch-silent --return-child-result -x index-file-$code.gdb \
+--args notmuch insert  < $gen_msg_filename"
+done
+
+for code in OUT_OF_MEMORY XAPIAN_EXCEPTION ; do
+test_expect_code 75 "EX_TEMPFAIL when add_message returns $code" \
+   "gdb --batch-silent --return-child-result -x index-file-$code.gdb \
+--args notmuch insert  < $gen_msg_filename"
 done
 
 test_done
-- 
2.10.2

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] cli/insert: delay database open until after writing mail file

2016-11-28 Thread David Bremner
The idea is to get the mail written to disk, even if we can't open the
database (e.g. because some other process has a write lock, and notmuch
is compiled for non-blocking opens).
---
 notmuch-insert.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/notmuch-insert.c b/notmuch-insert.c
index 131f09e..862da88 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -532,19 +532,19 @@ notmuch_insert_command (notmuch_config_t *config, int 
argc, char *argv[])
 action.sa_flags = 0;
 sigaction (SIGINT, , NULL);
 
-if (notmuch_database_open (notmuch_config_get_database_path (config),
-  NOTMUCH_DATABASE_MODE_READ_WRITE, ))
-   return EXIT_FAILURE;
-
-notmuch_exit_if_unmatched_db_uuid (notmuch);
-
 /* Write the message to the Maildir new directory. */
 newpath = maildir_write_new (config, STDIN_FILENO, maildir);
 if (! newpath) {
-   notmuch_database_destroy (notmuch);
return EXIT_FAILURE;
 }
 
+   if (notmuch_database_open (notmuch_config_get_database_path (config),
+  NOTMUCH_DATABASE_MODE_READ_WRITE, ))
+   return EXIT_FAILURE;
+
+notmuch_exit_if_unmatched_db_uuid (notmuch);
+
+
 /* Index the message. */
 status = add_file (notmuch, newpath, tag_ops, synchronize_flags, keep);
 
-- 
2.10.2

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Trouble decrypting multipart/encrypted

2016-11-28 Thread David Bremner
Eric Skoglund  writes:

> Hello, I've recently started using notmuch (together with emacs) and
> have now encountered some problems when trying to decrypt a
> multipart/encrypted message.

Is it just this one message, or all multipart/encrypted messages?

>
> Signing and encrypting email via C-c C-m s p and C-c C-m c p works
> fine. And given that it doesn't work outside of emacs I don't think it
> is an emacs problem. I'm also able to decrypt the message via the
> command line using just gpg.

Can you verify signed, non-encrypted messages (notmuch show --verify) ?

> Gpg2 version: 2.1.13
>
> I'm running fedora 24 with gnome if that helps.
>
> Any input on how to solve this issue is greatly appriciated.

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch