1. Software Freedom Conservancy
  2. Kallithea
  3. kallithea
  4. Issues

Issues

Issue #35 resolved

Zip downloads for git repos are corrupted

Michael DePalatis
created an issue

When attempting to download zip files for git repositories, the resulting download cannot be opened. I get this error message from file-roller (Gnome's archive manager program):

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.utf8,Utf16=on,HugeFiles=on,8 CPUs)

Error: /tmp/iontrap_address_list-790b5fb99094-2.zip: Can not open file as archive

Errors: 1

I have also confirmed with a colleague that files are not openable on Windows, either.

This issue only affects git repositories. Hg zip downloads work as expected.

Comments (5)

  1. Stefan Walter

    I can confirm this - I cannot unzip a downloaded ZIP file for a Git repository, either. On a Linux system, unzip says:

    Archive:  test.zip
      End-of-central-directory signature not found.  Either this file is not
      a zipfile, or it constitutes one disk of a multi-part archive.  In the
      latter case the central directory and zipfile comment will be found on
      the last disk(s) of this archive.
    unzip:  cannot find zipfile directory in one of test.zip or
            test.zip.zip, and cannot find test.zip.ZIP, period.
    

    I noticed that, suspiciously, the size of the ZIP file was 20480 bytes and did not change after I pushed a change into the repository and re-downloaded the ZIP file. Probably the file is simply truncated.

  2. Matt Fellows

    The fix for this is fairly trivial: edit <kalithea_home>/kalithea/controllers/files.py on approximately line 571 you should see:

                               cs.fill_archive(stream=temp_stream, kind=fileformat, subrepos=subrepos)
                               if not subrepos and archive_cache_enabled:
    

    change this to:

                               cs.fill_archive(stream=temp_stream, kind=fileformat, subrepos=subrepos)
                               temp_stream.close()
                               if not subrepos and archive_cache_enabled:
    

    And all your problems go away...

  3. Matt Fellows

    Also you will want to delete teh cached files in <kalithea_home>/cachedtarballs after applying this fix to ensure you download the fixed zip, not the cached broken zip

  4. Log in to comment