Code

Opened 3 years ago

Closed 22 months ago

#16964 closed Bug (duplicate)

FileField files can't be opened in write mode if not closed before

Reported by: jonash Owned by: nobody
Component: File uploads/storage Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The File associated with a FileField in a model object fetched from the db can't be opened in non-read mode. Test case and patch attached.

Attachments (2)

tests.diff (1.4 KB) - added by jonash 3 years ago.
Tests that demonstrate the bug
patch.diff (565 bytes) - added by jonash 3 years ago.
Patch that fixes the bug

Download all attachments as: .zip

Change History (9)

Changed 3 years ago by jonash

Tests that demonstrate the bug

Changed 3 years ago by jonash

Patch that fixes the bug

comment:1 Changed 3 years ago by ptone

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I haven't had time to play with the attached tests to verify the bug, but at a minimum, the attached patch would break the documented behavior:

https://docs.djangoproject.com/en/dev/ref/files/file/#django.core.files.File.open

comment:2 Changed 3 years ago by jonash

Why? The current behaviour doesn't match the docs: The file isn't reopened in a different mode although the explicit call to .open.

comment:3 Changed 2 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

It should probably only reopen (as opposed to seeking) if the mode is changed, patch is correct in principle.

comment:4 Changed 2 years ago by anonymous

bump

comment:5 Changed 2 years ago by jezdez

  • Needs tests set

comment:6 Changed 2 years ago by anonymous

already has tests, what's missing?

comment:7 Changed 22 months ago by claudep

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #13809

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.