Skip to content

Commit

Permalink
[zip-] fix loading and extracting files from url zip files #2127
Browse files Browse the repository at this point in the history
Regression occured in a1affe7
  • Loading branch information
anjakefala committed Nov 20, 2023
1 parent 9c31e8d commit 037b0d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions visidata/loaders/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class ZipSheet(Sheet):
def openZipFile(self, fp, *args, **kwargs):
'''Use VisiData input to handle password-protected zip files.'''
try:
return fp.open(*args, **kwargs)
return fp._open(*args, **kwargs)
except RuntimeError as err:
if 'password required' in err.args[0]:
pwd = vd.input(f'{args[0].filename} is encrypted, enter password: ', display=False)
return fp.open(*args, **kwargs, pwd=pwd.encode('utf-8'))
return fp._open(*args, **kwargs, pwd=pwd.encode('utf-8'))
vd.exceptionCaught(err)

def openRow(self, row):
Expand Down
2 changes: 1 addition & 1 deletion visidata/loaders/unzip_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def extract(self, member, path=None, pwd=None):

outpath = path/member
os.makedirs(outpath.parent, exist_ok=True)
with self.open(member) as fpin:
with self._open(member) as fpin:
with open(path/member, mode='wb') as fpout:
while True:
r = fpin.read(65536)
Expand Down

0 comments on commit 037b0d1

Please # to comment.