-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
LocalFileAdapter file deletion bug #2948
Comments
I can't repro this 🤔 I tested, and the code in the docs works fine. |
I see. That's odd. For reference, here's my config I'm using MongoDB as my DB. ` keystone.createList("TestPersonImage", { keystone.createList("TestPerson", { Note that I'm working directly with the TestPersonImage list and not the parent list. I'm performing CRUD from the admin panel. |
You need to have both sets of hooks from the example enabled. The first is a field-level hook; it handles the case where the file - and just the file - actually changed. The other is a list-level hook; it handles the case where the entire list entry was deleted. More info on hooks here: https://www.keystonejs.com/api/hooks/ |
@Vultraz the code above has it omitted. This because I was probably 10 tries in at that point pulling things out and putting them back in. But I have it noted down that even with both, it still doesn't work for me. |
@kasonde I've also been able to get this working... do you think you could post an example project to gitHub that has the bug? That way we can see if there's something different about your local environment or ideally get an example that allows us to reproduce the issue. Sorry about the trouble. If it turns out to be config, we can still improve the docs based on your experience! |
@MadeByMike I initially had the same issue with files not getting removed when I attempted to delete them. The way I fixed it is replacing the I'm fairly certain the docs explaining the file adapters don't say anything about using the field name as the property for |
It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :) |
Keystone 5 has officially moved into active maintenance mode as we push towards the next major new version Keystone Next, you can find out more information about this transition here. In an effort to sustain the project going forward, we're cleaning up and closing old issues such as this one. If you feel this issue is still relevant for Keystone Next, please let us know. |
Bug report
Describe the bug
In the documentation for file adapters, we're provided with a nifty hook to delete existing files before/after new ones are changed / deleted. Unfortunately the
existingItem
shown in the docs does not carry afile
property as show. So the condition is always false and files are never deleted.To Reproduce
Steps to reproduce the behaviour. Please provide code snippets or a repository:
Expected behaviour
I expect the existing file or in this case
existingItem.file
to be deleted.System information
The text was updated successfully, but these errors were encountered: