Kallithea issues archive

Issue #35: Zip downloads for git repos are corrupted

Reported by: Michael DePalatis
State: resolved
Created on: 2014-09-10 08:05
Updated on: 2014-12-08 23:50


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.



Comment by Stefan Walter, on 2014-11-27 11:02

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.

Comment by Matt Fellows, on 2014-11-27 14:25

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)
                           if not subrepos and archive_cache_enabled:

And all your problems go away...

Comment by Matt Fellows, on 2014-11-27 14:28

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

Comment by Stefan Walter, on 2014-11-28 08:32

I can confirm that adding that line and clearing the cache fixed it for me. Thanks!

Comment by Mads Kiilerich, on 2014-12-08 23:50