Stop decryption for all encrypted files when cancel is pressed
This commit is contained in:
parent
21206d4e3e
commit
65d12ae9e0
19
src/mdiary.c
19
src/mdiary.c
@ -383,7 +383,15 @@ static void mdiary_add_gpg_to_store(struct mdiary_scanner *mdiary_scanner,
|
|||||||
gchar *cmd_stderr = NULL;
|
gchar *cmd_stderr = NULL;
|
||||||
gint exit_status = 0;
|
gint exit_status = 0;
|
||||||
|
|
||||||
cmd = g_strdup_printf("gpg --decrypt %s", filename);
|
g_message("Decrypt file: %s", filename);
|
||||||
|
|
||||||
|
if (mdiary_scanner->gpg_enabled == 2) { /* GPG operation was manually cancelled */
|
||||||
|
g_warning("GPG: Skipping file.");
|
||||||
|
mdiary_scanner->entries_failed++; /* Simply count files that won't be decoded. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = g_strdup_printf("gpg --decrypt \"%s\"", filename);
|
||||||
|
|
||||||
if (g_spawn_command_line_sync(cmd, &cmd_stdout, &cmd_stderr, &exit_status, NULL) && exit_status == 0) {
|
if (g_spawn_command_line_sync(cmd, &cmd_stdout, &cmd_stderr, &exit_status, NULL) && exit_status == 0) {
|
||||||
g_message("GPG: Decryption OK!\n");
|
g_message("GPG: Decryption OK!\n");
|
||||||
@ -393,11 +401,16 @@ static void mdiary_add_gpg_to_store(struct mdiary_scanner *mdiary_scanner,
|
|||||||
} else {
|
} else {
|
||||||
mdiary_scanner->entries_failed++;
|
mdiary_scanner->entries_failed++;
|
||||||
mdiary_scanner->error_code |= MDS_ERROR_GPG;
|
mdiary_scanner->error_code |= MDS_ERROR_GPG;
|
||||||
g_warning("GPG: Decryption of message failed!\n"
|
g_warning("GPG: Decryption of message failed with error code %d!\n"
|
||||||
"---------- SNIP ----------\n"
|
"---------- SNIP ----------\n"
|
||||||
"%s"
|
"%s"
|
||||||
"---------- SNIP ----------\n",
|
"---------- SNIP ----------\n",
|
||||||
cmd_stderr ? cmd_stderr : "Unknown error.");
|
exit_status,
|
||||||
|
cmd_stderr ? cmd_stderr : "Unknown error.\n");
|
||||||
|
if (cmd_stderr && strstr(cmd_stderr, "Operation cancelled")) {
|
||||||
|
g_warning("GPG: Aborting import of further GPG messages.");
|
||||||
|
mdiary_scanner->gpg_enabled = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(cmd);
|
g_free(cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user