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

feat: expanded plugin unzipping #556

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
12 changes: 10 additions & 2 deletions backend/src/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from hashlib import sha256
from io import BytesIO
from logging import getLogger
from os import R_OK, W_OK, path, listdir, access, mkdir
from os import R_OK, W_OK, path, listdir, access, mkdir, path
from shutil import rmtree
from time import time
from zipfile import ZipFile
Expand Down Expand Up @@ -57,7 +57,15 @@ def _unzip_to_plugin_dir(self, zip: BytesIO, name: str, hash: str):
if hash and (zip_hash != hash):
return False
zip_file = ZipFile(zip)
zip_file.extractall(self.plugin_path)

files = zip_file.namelist()
if "plugin.json" in files:
zip_file.extractall(path.join(self.plugin_path, name))
if name in files:
zip_file.extractall(self.plugin_path)
if name + ".zip" in files:
return self._unzip_to_plugin_dir(BytesIO(zip_file.read(name + ".zip")), name, hash)

plugin_folder = self.find_plugin_folder(name)
assert plugin_folder is not None
plugin_dir = path.join(self.plugin_path, plugin_folder)
Expand Down