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
Documents with Image and File fields don't clean up orphaned files when they are removed #162
Comments
I like the prompt the admin user approach. Seems like it would be the easiest to implement in the near future. Reference checks tend to get messy and are difficult to get right. |
+1 for the UI Prompt |
I can't attach a schema post remove hook to cover this use case because Automattic/mongoose#1241 So this is really needed. |
The remove file button is not functional also. |
If this is an immediate and serious problem for anyone, one of the ways you can (probably?) work around it is discussed over here. |
As mentioned by @alanshaw in #161.
One solution would be to create a 'cleanup' method on Documents that gets the files and images referenced in any LocalFile, S3File, CloudinaryImage (etc) fields and deletes them.
It could potentially check for references to the same files in the same field in other documents in the collection first to make sure it didn't incorrectly remove files in use by other documents (e.g. because of duplication or copy/paste) - this may cause poor performance on unindexed fields in larger collections though.
We could also prompt in the Admin UI when Items are deleted to run the cleanup method (if the List has file fields in it), so the user has the choice.
Don't want to be too aggressive about automatically cleaning up but it would be good to have the option for Keystone to clean up after itself over time.
The text was updated successfully, but these errors were encountered: