After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 463235 - Can't add an empty directory with --add option
Can't add an empty directory with --add option
Status: RESOLVED FIXED
Product: file-roller
Classification: Applications
Component: general
2.19.x
Other Linux
: Normal minor
: ---
Assigned To: Paolo Bacchilega
file-roller-maint
Depends on:
Blocks:
 
 
Reported: 2007-08-03 19:38 UTC by Boyd Timothy
Modified: 2007-08-07 06:14 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
Include empty top-level directory in archive. (878 bytes, patch)
2007-08-04 01:11 UTC, Boyd Timothy
none Details | Review

Description Boyd Timothy 2007-08-03 19:38:34 UTC
Steps to reproduce:

1. Start with the following file structure

- EmptyDir
    (empty)
- NotEmptyDir
    - File1.txt
    - File2.txt
    - EmptyDir2
        (empty)

2. Highlight (in Nautilus) "EmptyDir" and "NotEmptyDir"
3. Right-click and select "Create archive..."
4. Name the archive "EmptyTest.zip" and press "Create"

nautilus-file-roller starts file-roller with this command:

file-roller --default-dir='/home/boyd/Desktop' --add '/home/boyd/Desktop/EmptyDir' '/home/boyd/Desktop/NotEmptyDir'

The EmptyTest.zip file is created with the following entries (notice that "EmptyDir" is *not* included:

/NotEmptyDir/File1.txt
/NotEmptyDir/File2.txt
/NotEmptyDir/EmptyDir2

I've been trying to track this one down without much success.  I'm guessing the problem is somewhere in src/file-list.c.  Can anyone give me a quick fix on this or point me in the right direction for what code I should look into?
Comment 1 Paolo Bacchilega 2007-08-03 21:58:51 UTC
Taking a quick look at the code you can try to set the property propAddCanStoreFolders to TRUE for fr-command-zip (the fr_command_init function in fr-command-zip.c) and then change the vd_path_list_done_cb function in src/file-list.c adding the visited folder to the list of files (vdd->files) if the folder was empty (pld->files and pld->dir are empty).
Comment 2 Boyd Timothy 2007-08-04 01:11:42 UTC
Created attachment 93073 [details] [review]
Include empty top-level directory in archive.

Thanks Paolo for the suggestion!  This patch works at least using EXE and tar.gz types.  I haven't had the time to test every single combination.  I had to add checks to make sure that the path contains no children (pld->files == null && pld->dirs == NULL) and also that it was a top-level directory.

I'm not sure if this is the most elegant way to go about fixing it, but this seems to work.  I added the test/addition before pld->files and pld->dirs gets nulled out.  I'm open to suggestions.
Comment 3 Paolo Bacchilega 2007-08-04 09:58:22 UTC
I've committed a change to svn trunk in which the base_dir is added to vdd->files in the visit_dir_async() function, it's also added to vdd->dirnames to prevent to add the directory more then once.

This seems to work for me, can you test it please?
Comment 4 Boyd Timothy 2007-08-04 14:26:12 UTC
(In reply to comment #3)
> I've committed a change to svn trunk in which the base_dir is added to
> vdd->files in the visit_dir_async() function, it's also added to vdd->dirnames
> to prevent to add the directory more then once.
> 
> This seems to work for me, can you test it please?
> 

Works great!  Thanks for the help on this one.