Menu

#234 advzip -a can't compress empty files

closed-fixed
nobody
None
3
2022-07-10
2011-06-26
Anonymous
No

rm -f t.zip empty
:>empty
echo foo >foo
advzip -a -4 t.zip empty foo

See the attached patch to fix it.

Discussion

  • Andrea Mazzoleni

    • priority: 5 --> 3
    • status: open --> closed-fixed
     
  • Thomas Debesse

    Thomas Debesse - 2022-07-09

    The bug isn't entirely fixed. Empty file is still not added to the archive if that's the only file to add to the archive:

    $ touch a
    $ advzip -a z.zip a
    a
    $ ls -1
    a
    
    $ touch a
    $ echo b > b
    $ advzip -a z.zip a b
    a
    b
    $ ls -1
    a
    b
    z.zip
    $ zipinfo -1 z.zip 
    a
    b
    
     

    Last edit: Thomas Debesse 2022-07-09
  • Thomas Debesse

    Thomas Debesse - 2022-07-09

    The same happens when re-compressing an archive if the archive only stores one empty file, it even deletes the to-be-compressed archive:

    $ touch a
    $ zip z.zip a
      adding: a (stored 0%)
    $ ls -1
    a
    z.zip
    $ advzip -z z.zip
    Failed stat file z.zip on z.zip [at unsigned int file_size(const string&):file.cc:199]
    $ ls -1
    a
    
    $ touch a
    $ echo b > b
    $ zip z.zip a b
      adding: a (stored 0%)
      adding: b (stored 0%)
    $ ls -1
    a
    b
    z.zip
    $ advzip -z z.zip
             284         180  63% z.zip
             284         180  63%
    $ ls -1
    a
    b
    z.zip
    $ zipinfo -1 z.zip
    a
    b
    
     
  • Thomas Debesse

    Thomas Debesse - 2022-07-10

    The same happens if the only file in the archive is a directory: advzip fails and the to-be-recompressed zip is deleted:

    $ mkdir d
    $ zip d.zip d
    $ ls -1
    d
    d.zip
    $ zipinfo -1 d.zip
    d/
    $ advzip -z d.zip
    Failed stat file d.zip on d.zip [at unsigned int file_size(const string&):file.cc:199]
    $ ls -1
    d
    
     

Log in to post a comment.

MongoDB Logo MongoDB