-
Notifications
You must be signed in to change notification settings - Fork 132
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
Fix wizzard apkm/zip split packages. #1387
base: async
Are you sure you want to change the base?
Changes from all commits
b7d84ae
e9098d7
4119ae8
ffb1b46
dc39ec9
3ddf47b
51e677b
7e76166
8f8a356
82d67a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
from mapadroid.mad_apk.wizard import APKWizard, PackageImporter, WizardError | ||
from mapadroid.madmin.AbstractMadminRootEndpoint import ( | ||
AbstractMadminRootEndpoint, check_authorization_header) | ||
from mapadroid.madmin.functions import allowed_file | ||
from mapadroid.utils.apk_enums import APKArch, APKType | ||
from mapadroid.utils.custom_types import MADapks | ||
|
||
|
@@ -39,6 +38,10 @@ async def get(self): | |
except KeyError: | ||
return await self._json_response(data=data[apk_type]) | ||
|
||
def allowed_file(self, filename): | ||
ALLOWED_EXTENSIONS = set(['apk', 'apkm', 'zip']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is equivalent to This should be a global variable thats initialized once and referenced instead of initialized on every call. |
||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS | ||
|
||
async def post(self): | ||
apk_type_raw: str = self.request.match_info.get('apk_type') | ||
apk_arch_raw: str = self.request.match_info.get('apk_arch') | ||
|
@@ -58,7 +61,7 @@ async def post(self): | |
elif not file.filename: | ||
await self._add_notice_message('No file selected for uploading') | ||
raise web.HTTPFound(self._url_for("upload")) | ||
elif not allowed_file(file.filename): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
elif not self.allowed_file(file.filename): | ||
await self._add_notice_message('Allowed file type is apk only!') | ||
raise web.HTTPFound(self._url_for("upload")) | ||
filename = secure_filename(file.filename) | ||
|
@@ -118,7 +121,7 @@ async def handle_file_upload(self, apk: io.BytesIO, apk_arch: Optional[APKArch], | |
except KeyError: | ||
return web.Response(text="Non-supported Type / Architecture", status=406) | ||
filename_split = filename.rsplit('.', 1) | ||
if filename_split[1] in ['zip', 'apks']: | ||
if filename_split[1] in ['zip', 'apkm']: | ||
mimetype = 'application/zip' | ||
elif filename_split[1] == 'apk': | ||
mimetype = 'application/vnd.android.package-archive' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like manifest is no longer used. Should be good to remove the line.