juliomalegria / django-chunked-upload

Upload large files to Django in multiple chunks, with the ability to resume if the upload is interrupted.
MIT No Attribution
214 stars 71 forks source link

Exception on delete when file field has no underlying filesystem object. #25

Closed dtrudg closed 8 years ago

dtrudg commented 8 years ago

If something goes wrong and a ChunkedUpload object is created, but the FileField does not have an underlying file on storage then delete() is impossible. Any attempt to delete the ChunkedUpload from the DB will raise an error:

   upload.delete()
  File "/home2/dtrudgian/Git/astrocyte/.venv/lib/python2.7/site-packages/chunked_upload/models.py", line 62, in delete
    storage, path = self.file.storage, self.file.path
  File "/home2/dtrudgian/Git/astrocyte/.venv/lib/python2.7/site-packages/django/db/models/fields/files.py", line 63, in _get_path
    self._require_file()
  File "/home2/dtrudgian/Git/astrocyte/.venv/lib/python2.7/site-packages/django/db/models/fields/files.py", line 46, in _require_file
    raise ValueError("The '%s' attribute has no file associated with it." % self.field.name)
ValueError: The 'file' attribute has no file associated with it.

See PR #24 for a possible solution?

juliomalegria commented 8 years ago

Fixed on pull request #24. Thanks @dctrud !