This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author longavailable
Recipients alanmcintyre, andrei.avk, longavailable, serhiy.storchaka, twouters
Date 2021-08-23.15:08:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <2021082323080007934816@126.com>
In-reply-to
Content
Serhiy: Thanks for your explanation. 

The file was created by zipfile module. I used the script hundreds of times, while only once (the uploaded zipped file) was abnormal. 

Since the project ended a long time ago, I cannot reproduce the error right now. I will post the related code snippet I used.

import zipfile
import pathlib

def fileIsValid(filename):
filename = pathlib.Path(filename)
return True if filename.is_file() and filename.stat().st_size > 0 else False

def compress2zip(sourceFile,zipFile,destinationFile):
if not fileIsValid(zipFile):
pathlib.Path(zipFile).parent.mkdir(parents=True, exist_ok=True)
with zipfile.ZipFile(zipFile,'w',compression=zipfile.ZIP_DEFLATED) as myzip:
myzip.write(sourceFile,destinationFile)
dest_size = myzip.getinfo(destinationFile).file_size
else:
with zipfile.ZipFile(zipFile,'a',compression=zipfile.ZIP_DEFLATED) as myzip:
if not destinationFile in myzip.namelist():
myzip.write(sourceFile,destinationFile)
dest_size = myzip.getinfo(destinationFile).file_size
source_size = pathlib.Path(sourceFile).stat().st_size
if source_size == dest_size:
print('Succeeded -- compress -- %s' % str(destinationFile))
return True
else:
print('Failed -- compress -- %s' %str(destinationFile))
return False

files = list(pathlib.Path('000-original').glob('*.geojson'))
zipFile = pathlib.Path('0000.zip')
for file in files:
comp_re = compress2zip(file, zipFile, file.name)
History
Date User Action Args
2021-08-23 15:08:11longavailablesetrecipients: + longavailable, twouters, alanmcintyre, serhiy.storchaka, andrei.avk
2021-08-23 15:08:11longavailablelinkissue41102 messages
2021-08-23 15:08:11longavailablecreate