From f87cc8ca8f3228ea47179f8645b8e09b97ec29da Mon Sep 17 00:00:00 2001 From: Scurest Date: Tue, 30 Jan 2024 10:23:55 +0100 Subject: [PATCH] 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 --- scripts/startup/bl_operators/userpref.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/startup/bl_operators/userpref.py b/scripts/startup/bl_operators/userpref.py index 1bfcd716ef2..b6a22fd3772 100644 --- a/scripts/startup/bl_operators/userpref.py +++ b/scripts/startup/bl_operators/userpref.py @@ -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)