[extensions-web/deploy] extensions: don't fail in Extension.save() if old zip is corrupted.
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web/deploy] extensions: don't fail in Extension.save() if old zip is corrupted.
- Date: Thu, 4 Apr 2019 15:23:09 +0000 (UTC)
commit 7a1191e76663f0f5f5eeff2ffb5729ec1ef935d8
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Thu Apr 4 19:22:49 2019 +0400
extensions: don't fail in Extension.save() if old zip is corrupted.
Saving Extension model trigger update of all extension versions as well as
extension's zip archives. Corrupted archive can be cause of BadZipfile
exception that we ignore. However zlib.error may be also thrown which also
should be handled.
Fixes: https://extensions.gnome.org/extension/1254/obmin/
sweettooth/extensions/models.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index ed4d452..c7d671a 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -10,6 +10,7 @@ from django.dispatch import Signal
import autoslug
import re
+import zlib
(STATUS_UNREVIEWED,
STATUS_REJECTED,
@@ -131,7 +132,7 @@ class Extension(models.Model):
if version.source:
try:
version.replace_metadata_json()
- except BadZipfile, e:
+ except (BadZipfile, zlib.error):
# Ignore bad zipfiles, we don't care
pass
@@ -254,7 +255,7 @@ def parse_zipfile_metadata(uploaded_file):
"""
try:
zipfile = ZipFile(uploaded_file, 'r')
- except BadZipfile:
+ except (BadZipfile, zlib.error):
raise InvalidExtensionData("Invalid zip file")
if zipfile.testzip() is not None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]