* [PATCH] new: Report and abort on upgrade failure
@ 2014-08-05 1:29 Austin Clements
2014-08-05 7:23 ` Tomi Ollila
2014-08-05 11:13 ` David Bremner
0 siblings, 2 replies; 5+ messages in thread
From: Austin Clements @ 2014-08-05 1:29 UTC (permalink / raw)
To: notmuch
Previously the return status of notmuch_database_upgrade went
completely unchecked.
---
notmuch-new.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/notmuch-new.c b/notmuch-new.c
index b7590a8..ddf42c1 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -923,6 +923,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_bool_t timer_is_active = FALSE;
notmuch_bool_t no_hooks = FALSE;
notmuch_bool_t quiet = FALSE, verbose = FALSE;
+ notmuch_status_t status;
add_files_state.verbosity = VERBOSITY_NORMAL;
add_files_state.debug = FALSE;
@@ -1019,9 +1020,16 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
}
gettimeofday (&add_files_state.tv_start, NULL);
- notmuch_database_upgrade (notmuch,
- add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,
- &add_files_state);
+ status = notmuch_database_upgrade (
+ notmuch,
+ add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,
+ &add_files_state);
+ if (status) {
+ printf ("Upgrade failed: %s\n",
+ notmuch_status_to_string (status));
+ notmuch_database_destroy (notmuch);
+ return EXIT_FAILURE;
+ }
if (add_files_state.verbosity >= VERBOSITY_NORMAL)
printf ("Your notmuch database has now been upgraded.\n");
}
@@ -1090,7 +1098,6 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
}
for (f = add_files_state.directory_mtimes->head; f && !interrupted; f = f->next) {
- notmuch_status_t status;
notmuch_directory_t *directory;
status = notmuch_database_get_directory (notmuch, f->filename, &directory);
if (status == NOTMUCH_STATUS_SUCCESS && directory) {
--
2.0.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] new: Report and abort on upgrade failure
2014-08-05 1:29 [PATCH] new: Report and abort on upgrade failure Austin Clements
@ 2014-08-05 7:23 ` Tomi Ollila
2014-08-05 11:13 ` David Bremner
1 sibling, 0 replies; 5+ messages in thread
From: Tomi Ollila @ 2014-08-05 7:23 UTC (permalink / raw)
To: Austin Clements, notmuch
On Tue, Aug 05 2014, Austin Clements <amdragon@MIT.EDU> wrote:
> Previously the return status of notmuch_database_upgrade went
> completely unchecked.
> ---
LGTM.
Tomi
> notmuch-new.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/notmuch-new.c b/notmuch-new.c
> index b7590a8..ddf42c1 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -923,6 +923,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
> notmuch_bool_t timer_is_active = FALSE;
> notmuch_bool_t no_hooks = FALSE;
> notmuch_bool_t quiet = FALSE, verbose = FALSE;
> + notmuch_status_t status;
>
> add_files_state.verbosity = VERBOSITY_NORMAL;
> add_files_state.debug = FALSE;
> @@ -1019,9 +1020,16 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
> }
>
> gettimeofday (&add_files_state.tv_start, NULL);
> - notmuch_database_upgrade (notmuch,
> - add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,
> - &add_files_state);
> + status = notmuch_database_upgrade (
> + notmuch,
> + add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,
> + &add_files_state);
> + if (status) {
> + printf ("Upgrade failed: %s\n",
> + notmuch_status_to_string (status));
> + notmuch_database_destroy (notmuch);
> + return EXIT_FAILURE;
> + }
> if (add_files_state.verbosity >= VERBOSITY_NORMAL)
> printf ("Your notmuch database has now been upgraded.\n");
> }
> @@ -1090,7 +1098,6 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
> }
>
> for (f = add_files_state.directory_mtimes->head; f && !interrupted; f = f->next) {
> - notmuch_status_t status;
> notmuch_directory_t *directory;
> status = notmuch_database_get_directory (notmuch, f->filename, &directory);
> if (status == NOTMUCH_STATUS_SUCCESS && directory) {
> --
> 2.0.0
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] new: Report and abort on upgrade failure
2014-08-05 1:29 [PATCH] new: Report and abort on upgrade failure Austin Clements
2014-08-05 7:23 ` Tomi Ollila
@ 2014-08-05 11:13 ` David Bremner
2014-08-05 14:33 ` [PATCH v2] " Austin Clements
1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2014-08-05 11:13 UTC (permalink / raw)
To: Austin Clements, notmuch
Austin Clements <amdragon@MIT.EDU> writes:
> Previously the return status of notmuch_database_upgrade went
> completely unchecked.
this doesn't apply to my tree. Did you maybe generate it post feature
patches or something?
d
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] new: Report and abort on upgrade failure
2014-08-05 11:13 ` David Bremner
@ 2014-08-05 14:33 ` Austin Clements
2014-08-06 13:41 ` David Bremner
0 siblings, 1 reply; 5+ messages in thread
From: Austin Clements @ 2014-08-05 14:33 UTC (permalink / raw)
To: notmuch
Previously the return status of notmuch_database_upgrade went
completely unchecked.
---
Quite right. v1 had some context that had been modified by my
features branch. Here's the same patch, but with context that should
work on master.
notmuch-new.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/notmuch-new.c b/notmuch-new.c
index d269c7c..5691005 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -923,6 +923,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_bool_t timer_is_active = FALSE;
notmuch_bool_t no_hooks = FALSE;
notmuch_bool_t quiet = FALSE, verbose = FALSE;
+ notmuch_status_t status;
add_files_state.verbosity = VERBOSITY_NORMAL;
add_files_state.debug = FALSE;
@@ -1019,9 +1020,16 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
}
gettimeofday (&add_files_state.tv_start, NULL);
- notmuch_database_upgrade (notmuch,
- add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,
- &add_files_state);
+ status = notmuch_database_upgrade (
+ notmuch,
+ add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,
+ &add_files_state);
+ if (status) {
+ printf ("Upgrade failed: %s\n",
+ notmuch_status_to_string (status));
+ notmuch_database_destroy (notmuch);
+ return EXIT_FAILURE;
+ }
if (add_files_state.verbosity >= VERBOSITY_NORMAL)
printf ("Your notmuch database has now been upgraded to database format version %u.\n",
notmuch_database_get_version (notmuch));
@@ -1091,7 +1099,6 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
}
for (f = add_files_state.directory_mtimes->head; f && !interrupted; f = f->next) {
- notmuch_status_t status;
notmuch_directory_t *directory;
status = notmuch_database_get_directory (notmuch, f->filename, &directory);
if (status == NOTMUCH_STATUS_SUCCESS && directory) {
--
2.0.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-06 13:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-05 1:29 [PATCH] new: Report and abort on upgrade failure Austin Clements
2014-08-05 7:23 ` Tomi Ollila
2014-08-05 11:13 ` David Bremner
2014-08-05 14:33 ` [PATCH v2] " Austin Clements
2014-08-06 13:41 ` 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).