From 7feafd79a481216cdd85b4828e749fc5efacb8db Mon Sep 17 00:00:00 2001 From: Matthew Stell Date: Tue, 24 Jun 2025 07:27:52 +0100 Subject: Fixed #35846 -- Ensured consistent path ordering in ManifestStaticFilesStorage manifest files. This change reuses the existing sorting of `hashed_files` in `ManifestStaticFilesStorage.save_manifest` to also store a sorted `paths` mapping in the manifest file. This ensures stable manifest output that does not change unnecessarily. --- tests/staticfiles_tests/test_storage.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index 35799f0ff7..9ef49491ff 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -568,6 +568,20 @@ class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase): self.assertEqual(manifest_hash, "") self.assertEqual(manifest_content, {"dummy.txt": "dummy.txt"}) + def test_manifest_file_consistent_content(self): + original_manifest_content = storage.staticfiles_storage.read_manifest() + hashed_files = storage.staticfiles_storage.hashed_files + # Force a change in the order of the hashed files. + with mock.patch.object( + storage.staticfiles_storage, + "hashed_files", + dict(reversed(hashed_files.items())), + ): + storage.staticfiles_storage.save_manifest() + manifest_file_content = storage.staticfiles_storage.read_manifest() + # The manifest file content should not change. + self.assertEqual(original_manifest_content, manifest_file_content) + @override_settings( STATIC_URL="/", -- cgit v1.3