浏览代码

Fixed #30802 -- Prevented manifest creation when running collectstatic in dry run mode.

pablo 5 年之前
父节点
当前提交
fa8fe09e4e
共有 2 个文件被更改,包括 7 次插入1 次删除
  1. 2 1
      django/contrib/staticfiles/storage.py
  2. 5 0
      tests/staticfiles_tests/test_management.py

+ 2 - 1
django/contrib/staticfiles/storage.py

@@ -398,7 +398,8 @@ class ManifestFilesMixin(HashedFilesMixin):
     def post_process(self, *args, **kwargs):
         self.hashed_files = {}
         yield from super().post_process(*args, **kwargs)
-        self.save_manifest()
+        if not kwargs.get('dry_run'):
+            self.save_manifest()
 
     def save_manifest(self):
         payload = {'paths': self.hashed_files, 'version': self.manifest_version}

+ 5 - 0
tests/staticfiles_tests/test_management.py

@@ -334,6 +334,11 @@ class TestCollectionDryRun(TestNoFilesCreated, CollectionTestCase):
         super().run_collectstatic(dry_run=True)
 
 
+@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.ManifestStaticFilesStorage')
+class TestCollectionDryRunManifestStaticFilesStorage(TestCollectionDryRun):
+    pass
+
+
 class TestCollectionFilesOverride(CollectionTestCase):
     """
     Test overriding duplicated files by ``collectstatic`` management command.