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

If two instances refer to the same file, deleting on of them causing file deletion #51

Closed
JediKnightChan opened this issue Aug 29, 2019 · 2 comments

Comments

@JediKnightChan
Copy link

If two instances have the same ImageField, deleting on of them causing file deletion.

@vinnyrose
Copy link
Collaborator

vinnyrose commented Aug 30, 2019

This seems within defined behavior for this app. I understand it is not ideal, but this type of expected behavior is more so a storage level concern or application design concern.

We look at per-instance changes of "strings". We don't actually look at "files" per se, just the "string" that somehow represents that file. When the conditions are right we tell the "string" to delete itself, how that command is interpreted is up to the storage class for that ImageField.

I would recommend one (or more) of:
Don't allow fields to reference the same file (database unique constraint?).
Rename files on upload if a conflict exists, or random file names.
If you need the same file often add a level of indirection to the same file using one of the media management plugins: https://djangopackages.org/grids/g/file-managers/
Looking for or make a custom storage backend to track file duplicates:
https://docs.djangoproject.com/en/dev/howto/custom-file-storage/
https://djangopackages.org/grids/g/storage-backends/

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants