summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjishengjie <[email protected]>2022-12-14 15:38:30 +0800
committermouse <[email protected]>2023-03-21 17:34:55 +0800
commitc279d858e62bb7d6dbca8e3686e22a5bf88c79f8 (patch)
tree63fc78a7c699373ab15d56ce32f2290707cd74e7
parentc16b9005558acb5d6cfa23259604c26f8919d8bd (diff)
downloadengrampa-c279d858e62bb7d6dbca8e3686e22a5bf88c79f8.tar.bz2
engrampa-c279d858e62bb7d6dbca8e3686e22a5bf88c79f8.tar.xz
fix: Encrypted documents in. 7z format cannot delete locked files and folders
-rw-r--r--src/fr-command-7z.c17
-rw-r--r--src/fr-window.c28
-rw-r--r--src/fr-window.h1
3 files changed, 45 insertions, 1 deletions
diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c
index c3c66ab..4c5b03a 100644
--- a/src/fr-command-7z.c
+++ b/src/fr-command-7z.c
@@ -394,12 +394,29 @@ fr_command_7z_add (FrCommand *comm,
}
static void
+process_line__delete (char *line,
+ gpointer data)
+{
+ FrCommand *comm = FR_COMMAND (data);
+
+ if ((strstr (line, "Wrong password?") != NULL)
+ || (strstr (line, "Enter password") != NULL))
+ {
+ password_required = TRUE;
+ }
+}
+
+static void
fr_command_7z_delete (FrCommand *comm,
const char *from_file,
GList *file_list)
{
GList *scan;
+ fr_process_set_out_line_func (comm->process,
+ process_line__delete,
+ comm);
+
fr_command_7z_begin_command (comm);
fr_process_add_arg (comm->process, "d");
if (spd_support) fr_process_add_arg (comm->process, "-spd");
diff --git a/src/fr-window.c b/src/fr-window.c
index 3c71431..8061a39 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -6317,14 +6317,34 @@ fr_window_archive_add_dropped_items (FrWindow *window,
window->priv->volume_size);
}
+static void
+remove_data_free (GList *rdata)
+{
+ g_list_free_full(rdata, g_free);
+}
+
void
fr_window_archive_remove (FrWindow *window,
GList *file_list)
{
+ char *password;
+ GList *remove_list;
+
fr_window_clipboard_remove_file_list (window, file_list);
fr_process_clear (window->archive->process);
- fr_archive_remove (window->archive, file_list, window->priv->compression);
+
+ remove_list = g_list_copy_deep (file_list, (GCopyFunc) g_strdup, NULL);
+ fr_window_set_current_batch_action (window,
+ FR_BATCH_ACTION_DELETE,
+ remove_list,
+ (GFreeFunc) remove_data_free);
+
+ password = window->priv->password;
+ if (password != NULL && password[0] != '\0')
+ g_object_set (window->archive->command, "password", password, NULL);
+
+ fr_archive_remove (window->archive, remove_list, window->priv->compression);
fr_process_start (window->archive->process);
}
@@ -8529,6 +8549,12 @@ fr_window_exec_batch_action (FrWindow *window,
fr_window_archive_add_dropped_items (window, (GList*) action->data, FALSE);
break;
+ case FR_BATCH_ACTION_DELETE:
+ debug (DEBUG_INFO, "[BATCH] DELETE\n");
+
+ fr_window_archive_remove (window, (GList*) action->data);
+ break;
+
case FR_BATCH_ACTION_OPEN:
debug (DEBUG_INFO, "[BATCH] OPEN\n");
diff --git a/src/fr-window.h b/src/fr-window.h
index 23ecaa0..5606dfe 100644
--- a/src/fr-window.h
+++ b/src/fr-window.h
@@ -53,6 +53,7 @@ typedef enum {
FR_BATCH_ACTION_LOAD,
FR_BATCH_ACTION_OPEN,
FR_BATCH_ACTION_ADD,
+ FR_BATCH_ACTION_DELETE,
FR_BATCH_ACTION_EXTRACT,
FR_BATCH_ACTION_EXTRACT_HERE,
FR_BATCH_ACTION_EXTRACT_INTERACT,