1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #35846 -- Improved reproducibility on staticfiles manifests.

Previously, the paths would appear in a nondeterministic order in the
resulting JSON file. I assume this would often reflect the order
in which files are listed by the operating system, given dict's
insertion order preservation, but there are probably many more factors
affecting this.

Sorting them results in more comparable results, smaller diffs and
(depending on the environment) more efficient deployments.
This commit is contained in:
Linus Heckemann 2024-10-15 16:19:15 +02:00
parent 7380ac5734
commit f3cd99a28d

View File

@ -504,7 +504,7 @@ class ManifestFilesMixin(HashedFilesMixin):
}
if self.manifest_storage.exists(self.manifest_name):
self.manifest_storage.delete(self.manifest_name)
contents = json.dumps(payload).encode()
contents = json.dumps(payload, sort_keys=True).encode()
self.manifest_storage._save(self.manifest_name, ContentFile(contents))
def stored_name(self, name):