[file-roller/gnome-3-8] cannot add files to a subfolder with zip and 7zip archives
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/gnome-3-8] cannot add files to a subfolder with zip and 7zip archives
- Date: Sun, 18 Aug 2013 12:05:02 +0000 (UTC)
commit 945b33f7ad10c45af64351c62e19d3d82df750c0
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Aug 18 14:03:27 2013 +0200
cannot add files to a subfolder with zip and 7zip archives
[bug #703420]
src/fr-archive.c | 1 +
src/fr-archive.h | 25 +++++++++++++++++++++++++
src/fr-command-7z.c | 1 +
src/fr-command.c | 7 ++++++-
src/glib-utils.c | 6 ++++++
5 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 410757d..2fb6162 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -450,6 +450,7 @@ fr_archive_init (FrArchive *self)
self->propAddCanReplace = FALSE;
self->propAddCanStoreFolders = FALSE;
self->propAddCanStoreLinks = FALSE;
+ self->propAddCanFollowDirectoryLinksWithoutDereferencing = TRUE;
self->propExtractCanAvoidOverwrite = FALSE;
self->propExtractCanSkipOlder = FALSE;
self->propExtractCanJunkPaths = FALSE;
diff --git a/src/fr-archive.h b/src/fr-archive.h
index 64866d1..f3f7956 100644
--- a/src/fr-archive.h
+++ b/src/fr-archive.h
@@ -121,6 +121,31 @@ struct _FrArchive {
*/
guint propAddCanStoreLinks : 1;
+ /* propAddCanFollowDirectoryLinksWithoutDereferencing:
+ *
+ * is used to overcome an issue with 7zip when adding a file in a
+ * subfolder. For example if we want to add to an archive
+ *
+ * /home/user/index.html
+ *
+ * in the folder 'doc'
+ *
+ * we create a symbolic link doc -> /home/user
+ *
+ * and use the following command to add the file
+ *
+ * 7z a -bd -y -mx=7 -- /home/user/archive.7z doc/index.html
+ *
+ * this gives an error because 7zip doesn't see the doc/index.html file
+ * for some reason, in this case we have to add the -l option to always
+ * deference the links.
+ *
+ * This means that when adding files to a subfolder in an 7zip archive
+ * we cannot store symbolic links as such, suboptimal but more
+ * acceptable than an error.
+ */
+ guint propAddCanFollowDirectoryLinksWithoutDereferencing : 1;
+
/* propExtractCanAvoidOverwrite:
*
* TRUE if the command can avoid to overwrite the files on disk.
diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c
index b34655c..f2e70a6 100644
--- a/src/fr-command-7z.c
+++ b/src/fr-command-7z.c
@@ -679,6 +679,7 @@ fr_command_7z_init (FrCommand7z *self)
base->propAddCanReplace = TRUE;
base->propAddCanStoreFolders = TRUE;
base->propAddCanStoreLinks = TRUE;
+ base->propAddCanFollowDirectoryLinksWithoutDereferencing = FALSE;
base->propExtractCanAvoidOverwrite = FALSE;
base->propExtractCanSkipOlder = FALSE;
base->propExtractCanJunkPaths = TRUE;
diff --git a/src/fr-command.c b/src/fr-command.c
index 2ac3671..69436de 100644
--- a/src/fr-command.c
+++ b/src/fr-command.c
@@ -721,7 +721,7 @@ create_tmp_base_dir (GFile *base_dir,
temp_dir = _g_file_get_temp_work_dir (NULL);
destination_parent = _g_path_remove_level (destination);
- parent_dir = _g_file_append_path (temp_dir, destination_parent, NULL);
+ parent_dir = _g_file_append_path (temp_dir, destination_parent, NULL);
debug (DEBUG_INFO, "mkdir %s\n", g_file_get_path (parent_dir));
_g_file_make_directory_tree (parent_dir, 0700, NULL);
@@ -951,6 +951,11 @@ _fr_command_add (FrCommand *self,
new_file_list = _g_string_list_dup (file_list);
}
+ /* see fr-archive.h for an explanation of the following code */
+
+ if (base_dir_created && ! archive->propAddCanFollowDirectoryLinksWithoutDereferencing)
+ follow_links = TRUE;
+
/* if the command cannot update, get the list of files that are
* newer than the ones in the archive. */
diff --git a/src/glib-utils.c b/src/glib-utils.c
index 37d4648..69adb30 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -919,6 +919,12 @@ _g_path_remove_level (const gchar *path)
if (p < 0)
return NULL;
+ /* ignore the first slash if it's the last character,
+ * this way /a/b/ is treated as /a/b */
+
+ if ((ptr[p] == '/') && (p > 0))
+ p--;
+
while ((p > 0) && (ptr[p] != '/'))
p--;
if ((p == 0) && (ptr[p] == '/'))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]