Addon: catch certain ZIP packaging errors in addon_install
One error that occurs when packaging a multi-file addon into a ZIP is zipping the contents of the addon, instead of the addon directory. When installing the ZIP using addon_install, the files that should be inside a directory instead get extracted into the top-level of the script directory. There was also no user feedback about what went wrong. Detect this case and fail with an error. Ref: !117664
This commit is contained in:
@@ -674,6 +674,13 @@ class PREFERENCES_OT_addon_install(Operator):
|
||||
return {'CANCELLED'}
|
||||
|
||||
file_to_extract_root = _zipfile_root_namelist(file_to_extract)
|
||||
|
||||
if "__init__.py" in file_to_extract_root:
|
||||
self.report({'ERROR'}, rpt_(
|
||||
"ZIP packaged incorrectly; __init__.py should be in a directory, not at top-level"
|
||||
))
|
||||
return {'CANCELLED'}
|
||||
|
||||
if self.overwrite:
|
||||
for f in file_to_extract_root:
|
||||
_module_filesystem_remove(path_addons, f)
|
||||
|
||||
Reference in New Issue
Block a user