-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fixes deletion of UploadChunk when Upload deletes #1322
Conversation
3c54edf
to
43a99e0
Compare
When running the reproducer without this patch I see leftover files. When running it with this patch I do not. |
A few questions:
|
Attached issue: https://pulp.plan.io/issues/7316 |
I was thinking about a test, but what seemed problematic is I can't predict the pk the file will get and there isn't a way to do it from the API. I could have the tools check |
I tried this actually and it is not. I tried the AFTER_DELETE hook, and the issue is that it also tries to watch the model for the |
That makes sense and I agree. I don't think a test is easy/possible. |
We can remove it, and I'm pushing a version now that will show the tests also passing. UploadChunk doesn't benefit from the |
According to the Django docs, the `on_delete=models.CASCADE` option does not call Model.delete(), but it does call the Model.post_delete() signal handler. This replaces the `UploadChunk.delete()` with an `UploadChunk.post_delete()` signal handler which correctly handles the `UploadChunk.file` file deletion. closes #7316
43a99e0
to
978680d
Compare
I think we should not for a few reasons. I did an audit and UploadChunk is the only model that both has a FileField or ArtifactFileField and has a ForeignKey with a cascade delete. That means in all the other cases the What I would like to do though is clean up in a variety of ways. I think we could do away with a lot of our code and have the same functionality. Should I file an issue for this? |
👍
I'm not sure I follow. |
+1 |
In terms of cleanup I mean that I don't think we need our custom storage backend, and I also don't think we need |
According to the Django docs, the
on_delete=models.CASCADE
option doesnot call Model.delete(), but it does call the Model.post_delete() signal
handler.
This replaces the
UploadChunk.delete()
with anUploadChunk.post_delete()
signal handler which correctly handlesthe
UploadChunk.file
file deletion.closes #7316