From 8c5e53faba98a96df844c9da2e3f2d8f75a5c2b3 Mon Sep 17 00:00:00 2001 From: Tingfeng Date: Wed, 22 Jun 2022 20:53:21 +0800 Subject: [PATCH] bytesio --- update_plugins.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/update_plugins.py b/update_plugins.py index 4a1a3e57..2b5d53e0 100644 --- a/update_plugins.py +++ b/update_plugins.py @@ -71,15 +71,11 @@ SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked") def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir): - temp_zip_path = path.join(temp_dir, plugin_name) - # Download and extract file in temp dir with urllib.request.urlopen(zip_path) as req: - with open(temp_zip_path, "wb") as f: - f.write(BytesIO(req.read())) - zip_f = zipfile.ZipFile(temp_zip_path) - zip_f.extractall(temp_dir) - content_disp = req.headers.get("Content-Disposition") + zip_f = zipfile.ZipFile(BytesIO(req.read())) + zip_f.extractall(temp_dir) + content_disp = req.headers.get("Content-Disposition") filename = re.findall("filename=(.+).zip", content_disp)[0] plugin_temp_path = path.join(temp_dir, path.join(temp_dir, filename))