From 5ad139ac1303e2d5ae38ba513b0b8773787ce7c2 Mon Sep 17 00:00:00 2001 From: gandalf3 Date: Sun, 2 Jul 2017 18:39:58 -0700 Subject: [PATCH] Quick hack to handle case of non-text, non-python files --- make_repo.py | 9 ++++++--- tests/test_helpers/addons/nonzip_nonaddon.tar | Bin 0 -> 20480 bytes 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 tests/test_helpers/addons/nonzip_nonaddon.tar diff --git a/make_repo.py b/make_repo.py index cad71af..03e02c8 100755 --- a/make_repo.py +++ b/make_repo.py @@ -91,9 +91,12 @@ def extract_blinfo(item: Path) -> dict: except zipfile.BadZipFile: # If it's not a valid zip, assume file is just a normal file - # TODO: this probably blows up inelegantly on corrupted zips - with item.open() as f: - blinfo = parse_blinfo(f.read()) + try: + with item.open() as f: + blinfo = parse_blinfo(f.read()) + except: #HACK + # If it's not a zip and its not parse-able python, then it's not an addon + raise BadAddon("File '%s' doesn't appear to be an addon" % item) # This should not happen if blinfo == None: diff --git a/tests/test_helpers/addons/nonzip_nonaddon.tar b/tests/test_helpers/addons/nonzip_nonaddon.tar new file mode 100644 index 0000000000000000000000000000000000000000..d74e2bdadf6f4d0886dcf82797fb37519b106363 GIT binary patch literal 20480 zcmeIuOA5j;5CG5|r6-W2KaV4YwjxL>)^0q#5x3Qq%QuV6WF~~+Qj_YwNqtORD8nwcp^AUrWB0pleGK=i3g;n@ z!*y