|
|
eb81ee |
From 3d9bfa9677960c1c03d795c1d5e849fc1ac4e18d Mon Sep 17 00:00:00 2001
|
|
|
eb81ee |
From: Paolo Bacchilega <paobac@src.gnome.org>
|
|
|
eb81ee |
Date: Sun, 15 Feb 2015 11:52:55 +0100
|
|
|
eb81ee |
Subject: Deleting all files does not work
|
|
|
eb81ee |
|
|
|
eb81ee |
only happens when the archive is modified with libarchive
|
|
|
eb81ee |
|
|
|
eb81ee |
[bug #738178]
|
|
|
eb81ee |
---
|
|
|
eb81ee |
src/fr-archive-libarchive.c | 24 +++++++++++++++++-------
|
|
|
eb81ee |
1 file changed, 17 insertions(+), 7 deletions(-)
|
|
|
eb81ee |
|
|
|
eb81ee |
diff --git a/src/fr-archive-libarchive.c b/src/fr-archive-libarchive.c
|
|
|
eb81ee |
index 8770f8a..6909b8a 100644
|
|
|
eb81ee |
--- a/src/fr-archive-libarchive.c
|
|
|
eb81ee |
+++ b/src/fr-archive-libarchive.c
|
|
|
eb81ee |
@@ -1641,6 +1641,7 @@ fr_archive_libarchive_add_files (FrArchive *archive,
|
|
|
eb81ee |
|
|
|
eb81ee |
typedef struct {
|
|
|
eb81ee |
GHashTable *files_to_remove;
|
|
|
eb81ee |
+ gboolean remove_all_files;
|
|
|
eb81ee |
int n_files_to_remove;
|
|
|
eb81ee |
} RemoveData;
|
|
|
eb81ee |
|
|
|
eb81ee |
@@ -1648,7 +1649,8 @@ typedef struct {
|
|
|
eb81ee |
static void
|
|
|
eb81ee |
remove_data_free (RemoveData *remove_data)
|
|
|
eb81ee |
{
|
|
|
eb81ee |
- g_hash_table_unref (remove_data->files_to_remove);
|
|
|
eb81ee |
+ if (remove_data->files_to_remove != NULL)
|
|
|
eb81ee |
+ g_hash_table_unref (remove_data->files_to_remove);
|
|
|
eb81ee |
g_free (remove_data);
|
|
|
eb81ee |
}
|
|
|
eb81ee |
|
|
|
eb81ee |
@@ -1662,7 +1664,7 @@ _remove_files_begin (SaveData *save_data,
|
|
|
eb81ee |
|
|
|
eb81ee |
fr_archive_progress_set_total_files (load_data->archive, remove_data->n_files_to_remove);
|
|
|
eb81ee |
fr_archive_progress_set_total_bytes (load_data->archive,
|
|
|
eb81ee |
- FR_ARCHIVE_LIBARCHIVE (load_data->archive)->priv->uncompressed_size);
|
|
|
eb81ee |
+ FR_ARCHIVE_LIBARCHIVE (load_data->archive)->priv->uncompressed_size);
|
|
|
eb81ee |
}
|
|
|
eb81ee |
|
|
|
eb81ee |
|
|
|
eb81ee |
@@ -1676,6 +1678,9 @@ _remove_files_entry_action (SaveData *save_data,
|
|
|
eb81ee |
WriteAction action;
|
|
|
eb81ee |
const char *pathname;
|
|
|
eb81ee |
|
|
|
eb81ee |
+ if (remove_data->remove_all_files)
|
|
|
eb81ee |
+ return WRITE_ACTION_SKIP_ENTRY;
|
|
|
eb81ee |
+
|
|
|
eb81ee |
action = WRITE_ACTION_WRITE_ENTRY;
|
|
|
eb81ee |
pathname = archive_entry_pathname (w_entry);
|
|
|
eb81ee |
if (g_hash_table_lookup (remove_data->files_to_remove, pathname) != NULL) {
|
|
|
eb81ee |
@@ -1701,12 +1706,17 @@ fr_archive_libarchive_remove_files (FrArchive *archive,
|
|
|
eb81ee |
GList *scan;
|
|
|
eb81ee |
|
|
|
eb81ee |
remove_data = g_new0 (RemoveData, 1);
|
|
|
eb81ee |
- remove_data->files_to_remove = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
|
|
eb81ee |
- remove_data->n_files_to_remove = 0;
|
|
|
eb81ee |
- for (scan = file_list; scan; scan = scan->next) {
|
|
|
eb81ee |
- g_hash_table_insert (remove_data->files_to_remove, g_strdup (scan->data), GINT_TO_POINTER (1));
|
|
|
eb81ee |
- remove_data->n_files_to_remove++;
|
|
|
eb81ee |
+ remove_data->remove_all_files = (file_list == NULL);
|
|
|
eb81ee |
+ if (! remove_data->remove_all_files) {
|
|
|
eb81ee |
+ remove_data->files_to_remove = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
|
|
eb81ee |
+ remove_data->n_files_to_remove = 0;
|
|
|
eb81ee |
+ for (scan = file_list; scan; scan = scan->next) {
|
|
|
eb81ee |
+ g_hash_table_insert (remove_data->files_to_remove, g_strdup (scan->data), GINT_TO_POINTER (1));
|
|
|
eb81ee |
+ remove_data->n_files_to_remove++;
|
|
|
eb81ee |
+ }
|
|
|
eb81ee |
}
|
|
|
eb81ee |
+ else
|
|
|
eb81ee |
+ remove_data->n_files_to_remove = archive->files->len;
|
|
|
eb81ee |
|
|
|
eb81ee |
_fr_archive_libarchive_save (archive,
|
|
|
eb81ee |
FALSE,
|
|
|
eb81ee |
--
|
|
|
eb81ee |
cgit v0.12
|
|
|
eb81ee |
|