Skip to content

Commit cf08042

Browse files
committed
Fixed a plugin issue when downloading
1 parent 53f930d commit cf08042

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cogs/plugins.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,16 @@ async def download_plugin(self, plugin, force=False):
173173
f.write(raw)
174174

175175
with zipfile.ZipFile(plugin_io) as zipf:
176-
for member in zipf.namelist():
177-
path = PurePath(member)
176+
for info in zipf.infolist():
177+
path = PurePath(info.filename)
178178
if len(path.parts) >= 3 and path.parts[1] == plugin.name:
179-
with zipf.open(member) as src, (
180-
plugin.abs_path / Path(*path.parts[2:])
181-
).open("wb") as dst:
182-
shutil.copyfileobj(src, dst)
179+
plugin_path = plugin.abs_path / Path(*path.parts[2:])
180+
if info.is_dir():
181+
plugin_path.mkdir(parents=True, exist_ok=True)
182+
else:
183+
plugin_path.parent.mkdir(parents=True, exist_ok=True)
184+
with zipf.open(info) as src, plugin_path.open("wb") as dst:
185+
shutil.copyfileobj(src, dst)
183186

184187
plugin_io.close()
185188

0 commit comments

Comments
 (0)