Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort ZIP Entries again #28

Closed
wants to merge 1 commit into from
Closed

Sort ZIP Entries again #28

wants to merge 1 commit into from

Commits on Feb 21, 2012

  1. Make ZipEntrySet return entries in sorted order.

    This ensures that the entries in the zip file's central directory are grouped
    together by folder, with each folder's directory entry coming before the
    folder's contents, rather than being in the random order dictated by Ruby's
    Hash implementation.
    
    Before:
    
      $ unzip -l before.zip
      Archive:  before.zip
        Length      Date    Time    Name
      ---------  ---------- -----   ----
              7  03-11-2011 14:14   fruit/apple
              8  03-11-2011 14:14   fruit/orange
              6  03-11-2011 14:14   fruit/kiwi
              0  03-11-2011 14:14   uuid/5D8976B4-C3B5-4FC6-A9BA-E307173F0064
              0  03-11-2011 14:14   uuid/
              0  03-11-2011 14:14   uuid/B1D55A18-860D-4BE1-BCB3-7DFBCD7C8BC4
              0  03-11-2011 14:14   uuid/E5E1F8F6-60A3-4733-9648-86711E7CD02A
              0  03-11-2011 14:14   fruit/
              8  03-11-2011 14:14   fruit/mango
              0  03-11-2011 14:14   Vegetable/
              0  03-11-2011 14:14   uuid/47FD714B-1A38-46AB-B9EF-0E8B2098D3A5
              0  03-11-2011 14:14   uuid/8B6FD77A-9A4C-4D74-B1E0-5B0EBBF0C3A9
              7  03-11-2011 14:14   Vegetable/celery
              8  03-11-2011 14:14   Vegetable/carrot
              6  03-11-2011 14:14   Vegetable/bean
      ---------                     -------
             50                     15 files
    
    After:
    
      $ unzip -l after.zip
      Archive:  after.zip
        Length      Date    Time    Name
      ---------  ---------- -----   ----
              0  03-11-2011 14:15   Vegetable/
              6  03-11-2011 14:15   Vegetable/bean
              8  03-11-2011 14:15   Vegetable/carrot
              7  03-11-2011 14:15   Vegetable/celery
              0  03-11-2011 14:15   fruit/
              7  03-11-2011 14:15   fruit/apple
              6  03-11-2011 14:15   fruit/kiwi
              8  03-11-2011 14:15   fruit/mango
              8  03-11-2011 14:15   fruit/orange
              0  03-11-2011 14:15   uuid/
              0  03-11-2011 14:15   uuid/47FD714B-1A38-46AB-B9EF-0E8B2098D3A5
              0  03-11-2011 14:15   uuid/5D8976B4-C3B5-4FC6-A9BA-E307173F0064
              0  03-11-2011 14:15   uuid/8B6FD77A-9A4C-4D74-B1E0-5B0EBBF0C3A9
              0  03-11-2011 14:15   uuid/B1D55A18-860D-4BE1-BCB3-7DFBCD7C8BC4
              0  03-11-2011 14:15   uuid/E5E1F8F6-60A3-4733-9648-86711E7CD02A
      ---------                     -------
             50                     15 files
    
    Similar functionality has been committed before (see commit 74e4512),
    but was reverted in commit 963f23c because it
    breaks things (like EPUB) that require entries to appear in a particular order.
    
    This re-enables sorting by default, but still allows custom ZipEntrySet
    implementations to be used when a custom sort order is required.
    dlitz committed Feb 21, 2012
    Configuration menu
    Copy the full SHA
    d741937 View commit details
    Browse the repository at this point in the history