From a9d03c409406f3f95f692bc5545ebacc7f4e2e4f Mon Sep 17 00:00:00 2001 From: Gaƫl Utard Date: Sat, 15 Feb 2025 15:55:33 +0100 Subject: [5.1.x] Fixed #36191 -- Truncated the overwritten file content in FileSystemStorage. Backport of 0d1dd6bba0c18b7feb6caa5cbd8df80fbac54afd from main. --- django/core/files/storage/filesystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'django/core/files/storage/filesystem.py') diff --git a/django/core/files/storage/filesystem.py b/django/core/files/storage/filesystem.py index bf2b9caad4..1bd9aa0a6c 100644 --- a/django/core/files/storage/filesystem.py +++ b/django/core/files/storage/filesystem.py @@ -129,11 +129,11 @@ class FileSystemStorage(Storage, StorageSettingsMixin): ) # RemovedInDjango60Warning: when the deprecation ends, replace with: # if self._allow_overwrite: - # open_flags = open_flags & ~os.O_EXCL + # open_flags = open_flags & ~os.O_EXCL | os.O_TRUNC if self.OS_OPEN_FLAGS != open_flags: open_flags = self.OS_OPEN_FLAGS elif self._allow_overwrite: - open_flags = open_flags & ~os.O_EXCL + open_flags = open_flags & ~os.O_EXCL | os.O_TRUNC fd = os.open(full_path, open_flags, 0o666) _file = None try: -- cgit v1.3