[extensions-web/wip/api/v1: 9/19] extensions: do not rewrite all extension zip files
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web/wip/api/v1: 9/19] extensions: do not rewrite all extension zip files
- Date: Sun, 20 Dec 2020 14:26:11 +0000 (UTC)
commit 6db0ec17ac5126afeecd2242a7c422138885a04e
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Sat May 23 14:00:23 2020 +0400
extensions: do not rewrite all extension zip files
sweettooth/extensions/models.py | 11 ++---------
sweettooth/extensions/views.py | 6 +++---
2 files changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index 6d83ae87..fe4ae3ef 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -16,6 +16,7 @@ import os
import re
import zlib
+from datetime import datetime
from zipfile import ZipFile, BadZipfile
from django.conf import settings
@@ -138,16 +139,8 @@ class Extension(models.Model):
if not validate_uuid(self.uuid):
raise ValidationError("Your extension has an invalid UUID")
- def save(self, replace_metadata_json=True, *args, **kwargs):
+ def save(self, *args, **kwargs):
super().save(*args, **kwargs)
- if replace_metadata_json:
- for version in self.versions.all():
- if version.source:
- try:
- version.replace_metadata_json()
- except (BadZipfile, zlib.error):
- # Ignore bad zipfiles, we don't care
- pass
def get_absolute_url(self):
return reverse('extensions-detail', kwargs=dict(pk=self.pk,
diff --git a/sweettooth/extensions/views.py b/sweettooth/extensions/views.py
index da165e51..dd2c58a4 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -114,7 +114,7 @@ def shell_download(request, uuid):
raise Http404()
extension.downloads += 1
- extension.save(replace_metadata_json=False)
+ extension.save()
return redirect(version.source.url)
@@ -377,7 +377,7 @@ def ajax_upload_screenshot_view(request, extension):
extension.screenshot = data
extension.full_clean()
- extension.save(replace_metadata_json=False)
+ extension.save()
return extension.screenshot.url
@ajax_view
@@ -390,7 +390,7 @@ def ajax_upload_icon_view(request, extension):
extension.icon = data
extension.full_clean()
- extension.save(replace_metadata_json=False)
+ extension.save()
return extension.icon.url
def ajax_details(extension, version=None):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]