# Issue 35326 (OverwritingStorageTests) design discussion

**URL:** <https://forum.djangoproject.com/t/issue-35326-overwritingstoragetests-design-discussion/29462>\
**Category:** Django Internals\
**Created:** [March 25, 2024, 2:30pm UTC](https://forum.djangoproject.com/t/issue-35326-overwritingstoragetests-design-discussion/29462 "2024-03-25T14:30:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/benc/32/16767_2.png) [@benc](https://forum.djangoproject.com/u/benc)\
**Post date:** [March 25, 2024, 2:30pm UTC](https://forum.djangoproject.com/t/issue-35326-overwritingstoragetests-design-discussion/29462/1 "2024-03-25T14:30:02Z")

</div>

I opened [issue 35326](https://code.djangoproject.com/ticket/35326) - there’s a hook in FileSystemStorage for overwriting `OS_OPEN_FLAGS` to allow changing the storage to (for example) allow overwriting files instead of getting a new file name if there’s a file name collision. This feature is tested, but fails if an upload written to a temporary file (instead of staying in memory) is used.

See the issue for an example test that fails. How should we update the design so temporary files work also?

---

<div class="post-metadata">

**Author:** ![benc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/benc/32/16767_2.png) [@benc](https://forum.djangoproject.com/u/benc)\
**Post date:** [March 25, 2024, 2:42pm UTC](https://forum.djangoproject.com/t/issue-35326-overwritingstoragetests-design-discussion/29462/2 "2024-03-25T14:42:36Z")

</div>

In the work where this feature was added, there was a [rejected option](https://github.com/jonprindiville/django/compare/ticket_28144...ticket_28144--class-attribute) where an `ALLOW_OVERWRITE` flag was added to the FileSystemStorage.

---

<div class="post-metadata">

**Author:** ![benc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/benc/32/16767_2.png) [@benc](https://forum.djangoproject.com/u/benc)\
**Post date:** [March 26, 2024, 12:44pm UTC](https://forum.djangoproject.com/t/issue-35326-overwritingstoragetests-design-discussion/29462/3 "2024-03-26T12:44:06Z")

</div>

Since the feature allowing file overwrite using the OS\_OPEN\_FLAGS is broken in some cases, what if we deprecate OS\_OPEN\_FLAGS, add an ALLOW\_OVERWRITE boolean, and then we could check that boolean to allow file overwrite where the file is in memory or written to a temporary file?

(Although OS\_OPEN\_FLAGS doesn’t appear to be documented, so maybe it wouldn’t need to go through a deprecation period?)

---

<div class="post-metadata">

**Author:** ![benc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/benc/32/16767_2.png) [@benc](https://forum.djangoproject.com/u/benc)\
**Post date:** [March 26, 2024, 3:35pm UTC](https://forum.djangoproject.com/t/issue-35326-overwritingstoragetests-design-discussion/29462/4 "2024-03-26T15:35:29Z")

</div>

I opened a [draft PR](https://github.com/django/django/pull/18020).

---

<div class="post-metadata">

**Author:** ![sarahboyce](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sarahboyce/32/12734_2.png) [@sarahboyce](https://forum.djangoproject.com/u/sarahboyce)\
**Post date:** [April 24, 2024, 7:52am UTC](https://forum.djangoproject.com/t/issue-35326-overwritingstoragetests-design-discussion/29462/5 "2024-04-24T07:52:35Z")

</div>

I think the PR is coming along nicely and I like the suggested design 👍

> OS\_OPEN\_FLAGS doesn’t appear to be documented, so maybe it wouldn’t need to go through a deprecation period?

I think let’s deprecate, although most instances I’ve found of people using `OS_OPEN_FLAGS` is a direct copy and paste, at least the warning encourages users to remove this and there’s a chance it is in use.
