mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
[5.2.x] Fixed #36191 -- Truncated the overwritten file content in FileSystemStorage.
Backport of 0d1dd6bba0 from main.
This commit is contained in:
@@ -704,6 +704,18 @@ class OverwritingStorageTests(FileStorageTests):
|
||||
finally:
|
||||
self.storage.delete(name)
|
||||
|
||||
def test_save_overwrite_behavior_truncate(self):
|
||||
name = "test.file"
|
||||
original_content = b"content extra extra extra"
|
||||
new_smaller_content = b"content"
|
||||
self.storage.save(name, ContentFile(original_content))
|
||||
try:
|
||||
self.storage.save(name, ContentFile(new_smaller_content))
|
||||
with self.storage.open(name) as fp:
|
||||
self.assertEqual(fp.read(), new_smaller_content)
|
||||
finally:
|
||||
self.storage.delete(name)
|
||||
|
||||
def test_save_overwrite_behavior_temp_file(self):
|
||||
"""Saving to same file name twice overwrites the first file."""
|
||||
name = "test.file"
|
||||
|
||||
Reference in New Issue
Block a user