Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files are deleted from S3 before a model instance is saved #972

Closed
oliverroick opened this issue Dec 6, 2016 · 0 comments · Fixed by #1010
Closed

Files are deleted from S3 before a model instance is saved #972

oliverroick opened this issue Dec 6, 2016 · 0 comments · Fixed by #1010
Assignees

Comments

@oliverroick
Copy link
Member

Steps to reproduce the error

  1. Create a resource or upload an XLSForm to a project and save.
  2. Edit the resource or project and click "remove" next to the file field.
  3. Cancel editing.
  4. Try to access the file on S3.

Actual behavior

The file is deleted from S3, whether the model instance is saved or not. If the user removes the file from the field and then cancels editing, the database will still have the link but the resource does not exist.

Expected behavior

The file should only be deleted when the model instance is actually saved. That means removing the file from S3 should be moved from django-buckets into the respective model. Before saving we need to check whether the file was removed and then delete the file from S3. If the file was replace with a new file, the old file should be removed.

Currently, this affects the following models (probably not exhaustive):

  • Project (for XLSForms)
  • Resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants