Ticket UUID: | 923a9123096ae70e565558a274522fecc5c73771 | ||
Title: | osx will not unzip the zip files created by fossil | ||
Status: | Fixed | Type: | Incident |
Severity: | Important | Priority: | |
Subsystem: | Resolution: | Fixed | |
Last Modified: | 2009-10-18 18:35:27 | ||
Version Found In: | e124881a70 | ||
Description & Comments: | |||
osx will not unzip the zip files created by fossil
to replicate the problem ; 1. login as anonymous to fossil-scm.org 2. choose either timeline or leaves 3. click on a 'version'(?) to open the summary page 4. click on 'ZIP archive' to start download. 5. download completed; either a) choose unzip as the default action, or b) double-click from finder. (behaviour noted in osx 10.5) drh added on 2009-07-13 14:13:50: anonymous added on 2009-07-16 22:48:57: anonymous claiming to be Dmitry Chestnykh added on 2009-10-18 15:31:44: This fixes the issue with ditto. (As discussed here) --- src/zip.c +++ src/zip.c @@ -126,11 +126,10 @@ ** that the file should be saved as. */ void zip_add_file(const char *zName, const Blob *pFile){ z_stream stream; int nameLen; - int skip; int toOut; int iStart; int iCRC = 0; int nByte = 0; int nByteCompr = 0; @@ -177,53 +176,37 @@ blob_append(&body, zHdr, 30); blob_append(&body, zName, nameLen); blob_append(&body, zExTime, 13); if( nBlob>0 ){ - /* The first two bytes that come out of the deflate compressor are - ** some kind of header that ZIP does not use. So skip the first two - ** output bytes. - */ - skip = 2; - /* Write the compressed file. Compute the CRC as we progress. */ stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; stream.opaque = 0; stream.avail_in = blob_size(pFile); stream.next_in = (unsigned char*)blob_buffer(pFile); stream.avail_out = sizeof(zOutBuf); stream.next_out = (unsigned char*)zOutBuf; - deflateInit(&stream, 9); + deflateInit2(&stream, 9, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY); iCRC = crc32(0, stream.next_in, stream.avail_in); while( stream.avail_in>0 ){ deflate(&stream, 0); toOut = sizeof(zOutBuf) - stream.avail_out; - if( toOut>skip ){ - blob_append(&body, &zOutBuf[skip], toOut - skip); - skip = 0; - }else{ - skip -= toOut; - } + blob_append(&body, zOutBuf, toOut); stream.avail_out = sizeof(zOutBuf); stream.next_out = (unsigned char*)zOutBuf; } do{ stream.avail_out = sizeof(zOutBuf); stream.next_out = (unsigned char*)zOutBuf; deflate(&stream, Z_FINISH); toOut = sizeof(zOutBuf) - stream.avail_out; - if( toOut>skip ){ - blob_append(&body, &zOutBuf[skip], toOut - skip); - skip = 0; - }else{ - skip -= toOut; - } + blob_append(&body, zOutBuf, toOut); }while( stream.avail_out==0 ); nByte = stream.total_in; - nByteCompr = stream.total_out - 2; + nByteCompr = stream.total_out; deflateEnd(&stream); /* Go back and write the header, now that we know the compressed file size. */ z = &blob_buffer(&body)[iStart]; |