From 5f7b8465d05279a5a9dab01f28d9fc02e104ba81 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 19 Jun 2014 10:04:16 -0700 Subject: [PATCH] Fixed issue with extractZip function. --- sickbeard/helpers.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 7ff9c1e6..2df9d924 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -1183,18 +1183,20 @@ def extractZip(archive, targetDir): if not os.path.exists(targetDir): os.mkdir(targetDir) - with zipfile.ZipFile(archive) as zip_file: - for member in zip_file.namelist(): - filename = os.path.basename(member) - # skip directories - if not filename: - continue + zip_file = zipfile.ZipFile(archive, 'r') + for member in zip_file.namelist(): + filename = os.path.basename(member) + # skip directories + if not filename: + continue - # copy file (taken from zipfile's extract) - source = zip_file.open(member) - target = file(os.path.join(targetDir, filename), "wb") - with source, target: - shutil.copyfileobj(source, target) + # copy file (taken from zipfile's extract) + source = zip_file.open(member) + target = file(os.path.join(targetDir, filename), "wb") + shutil.copyfileobj(source, target) + source.close() + target.close() + zip_file.close() return True except: return False \ No newline at end of file