Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DD_MAGIC reversed #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zipstream/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
DD_STRUCT64 = struct.Struct(b"<LQQ")
DD_TUPLE = namedtuple("filecrc",
("crc", "comp_size", "uncomp_size"))
DD_MAGIC = b'\x08\x07\x4b\x50'
DD_MAGIC = b'\x50\x4b\x07\x08'


# central directory file header
Expand Down
12 changes: 12 additions & 0 deletions zipstream/zipstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
import os
import time
import urllib
import zlib
from . import consts

Expand Down Expand Up @@ -113,6 +114,9 @@ def _create_file_struct(self, data):
if 'file' in data:
file_struct['src'] = data['file']
file_struct['stype'] = 'f'
elif 'url' in data:
file_struct['src'] = data['url']
file_struct['stype'] = 'u'
elif 'stream' in data:
file_struct['src'] = data['stream']
file_struct['stype'] = 's'
Expand Down Expand Up @@ -274,6 +278,14 @@ def data_generator(self, src, src_type):
break
yield part
return
if src_type == 'u':
with urllib.request.urlopen(src) as fh:
while True:
part = fh.read(self.chunksize)
if not part:
break
yield part
return

def _stream_single_file(self, file_struct):
"""
Expand Down