[extensions-web/wip/api/v1: 4/17] extensions: do not rewrite all extension zip files




commit f278eb5398de946540346824b25cf5c3f029af74
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 b050e236..3c80c9fc 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
@@ -140,16 +141,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 6d8442af..be931b95 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)
 
@@ -378,7 +378,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
@@ -391,7 +391,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]