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




commit e893d66fb0ebb5ee6fd5f02acad2822ef9b339eb
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 8a53802..dbd618e 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -17,6 +17,7 @@ import os
 import re
 import zlib
 
+from datetime import datetime
 from zipfile import ZipFile, BadZipfile
 
 from django.conf import settings
@@ -154,16 +155,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 1594ec8..d3b6bd2 100644
--- a/sweettooth/extensions/views.py
+++ b/sweettooth/extensions/views.py
@@ -121,7 +121,7 @@ def shell_download(request, uuid):
         raise Http404()
 
     extension.downloads += 1
-    extension.save(replace_metadata_json=False)
+    extension.save()
 
     return redirect(version.source.url)
 
@@ -390,7 +390,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
@@ -403,7 +403,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]