Skip to content

Commit

Permalink
add comments for when deprecation ends
Browse files Browse the repository at this point in the history
  • Loading branch information
bcail committed May 9, 2024
1 parent f7a168b commit 2cb63d6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions django/core/files/storage/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ class FileSystemStorage(Storage, StorageSettingsMixin):
Standard filesystem storage
"""

# RemovedInDjango60Warning: when the deprecation ends, all uses of
# OS_OPEN_FLAGS in this class should be removed, except the flags needed
# inside the _save() method.
# RemovedInDjango60Warning: when the deprecation ends, remove this
# OS_OPEN_FLAGS definition.
# The combination of O_CREAT and O_EXCL makes os.open() raise OSError if
# the file already exists before it's opened.
OS_OPEN_FLAGS = os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, "O_BINARY", 0)
Expand All @@ -47,6 +46,8 @@ def __init__(
self._directory_permissions_mode = directory_permissions_mode
self._allow_overwrite = allow_overwrite
setting_changed.connect(self._clear_cached_properties)
# RemovedInDjango60Warning: when the deprecation ends, remove this
# warning.
if self.OS_OPEN_FLAGS != os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(
os, "O_BINARY", 0
):
Expand Down Expand Up @@ -137,6 +138,11 @@ def _save(self, name, content):

# This is a normal uploadedfile that we can stream.
else:
# RemovedInDjango60Warning: when the deprecation ends, replace with:
# open_flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL |
# getattr(os, "O_BINARY", 0)
# if self._allow_overwrite:
# open_flags = open_flags & ~os.O_EXCL
if (
self.OS_OPEN_FLAGS
== os.O_WRONLY
Expand Down

0 comments on commit 2cb63d6

Please sign in to comment.