3

I get DeprecationWarning: struct integer overflow masking is deprecated error in z.write when file arrives to 4GB.

My code:

def compressOutputFile(outputFileName, outputPath=UXConfig.myPath):
  os.chdir(outputPath)
  z= zipfile.ZipFile(outputFileName+'.zip', 'wb',zipfile.ZIP_DEFLATED,allowZip64=True)
  UXUtils.log('Writting file')
  z.write(outputFileName)
  UXUtils.log('Writting finished')
  z.close()
  tempFiles.append(outputPath+outputFileName)

The file isn't corrupted because I can open and see the lines.

Laura Abad Avilés
  • 776
  • 1
  • 7
  • 16

1 Answers1

1

I never used the zipfile module but I used a with statement and tried it against an 8GB file and it worked (from 8GB to 44MB :o):

def zipItUp(file):
    with zipfile.ZipFile('zipped.zip', 'w', compression=zipfile.ZIP_DEFLATED, allowZip64=True) as zipped:
        zipped.write(file)

See if this does anything. If not, I think the only other solution I can think of is partitioning your file up and then the zip on each chunk.

EDIT: If you're using Python 2.6, then consider including the contextlib module to handle the exit error as referenced in this topic.

Here would be the revised code:

import contextlib

def zipItUp(file):
    with contextlib.closing(zipfile.ZipFile('zipped.zip', 'w', compression=zipfile.ZIP_DEFLATED, allowZip64=True)) as zipped:
        zipped.write(file)

See if this works. Cheers!

Community
  • 1
  • 1
Scratch'N'Purr
  • 9,959
  • 2
  • 35
  • 51