#27334: File uploads create copies instead of renaming ----------------------------+---------------------------------------------- Reporter: Adam | Owner: nobody Chidlow | Type: Bug | Status: new Component: | Version: 1.10 Uncategorized | Severity: Normal | Keywords: FileField, TemporaryUploadedFile Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------+---------------------------------------------- Using default settings, when a file is uploaded and is greater than 2.5MB it will get saved as a temporary file. However even if that temporary file is on the same file system as MEDIA_ROOT, it will be copied instead of moved.
This appears to be because FileField.pre_save passes the FieldFile as 'content' to Storage.save(), instead of FieldFile.file, which is the TemporaryUploadedFile having a temporary_file_path attribute thus invoking file_move_safe. This appears to have been the behaviour from the beginning: [https://github.com/django/django/blame/master/django/db/models/fields/files.py#L296] For large uploaded files this has some undesirable consequences, it increases the time for the request to complete, and when running Django certain ways (at least under gunicorn using gthread workers), the temporary file won't be closed until that worker has recieved another request, so it's taking up double the storage for that time. -- Ticket URL: <https://code.djangoproject.com/ticket/27334> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.ce85ae5dfc09839a7d249229d9af5a1e%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.