Opened 16 years ago

Closed 13 years ago

#7844 closed Bug (fixed)

Very small race condition in file field saving

Reported by: Malcolm Tredinnick Owned by: nobody
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Noticed this whilst reading Model._save_FIELD_file() for another reason. The directory name used to save the file can be sensitive to the current datetime value, since upload_to directories can contain format strings. This directory name is computed a couple of times in this function, from what I can work out: once when creating the directories at the top of the function and once when call field.get_filename().

It's possible that the time delay between creating the directory and using the directory lower down could be sufficiently long that the name actually changes. For example, using day-based formats and then clock crosses midnight. The directory name should be the same throughout the code.

Attachments (1)

7844.diff (1.3 KB ) - added by scum 16 years ago.
Added a optional parameter to get_filename fixingthe race condition. Not as pretty, but the only way I can think to do it right.

Download all attachments as: .zip

Change History (4)

comment:1 by Malcolm Tredinnick, 16 years ago

Triage Stage: UnreviewedAccepted

by scum, 16 years ago

Attachment: 7844.diff added

Added a optional parameter to get_filename fixingthe race condition. Not as pretty, but the only way I can think to do it right.

comment:2 by Luke Plant, 14 years ago

Severity: Normal
Type: Bug

comment:3 by Koen Biermans, 13 years ago

Easy pickings: unset
Resolution: fixed
Status: newclosed
UI/UX: unset

This part of the code was changed drastically in the file storage refactor. I can not find a similar race condition in the current FileField implementation.

Closing as fixed.

Note: See TracTickets for help on using tickets.
Back to Top