Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
fix: fail to delete multiple files if the files are removed from upstream storage #2317
fix: fail to delete multiple files if the files are removed from upstream storage #2317
Changes from 3 commits
3f5a4a1
390b244
36c40f8
63be71a
7b0299e
b6f245a
9e861a2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果删除了异常catch,那么可能因为网络问题而导致删除失败时,halo中的数据库记录却被删除了的问题从而导致文件遗留。
建议先查询一次来判断 bucket 中是否存在文件,如果不存在则直接跳到删除数据库记录的逻辑,否则不需要改变原来的逻辑,用户可以通过手动重试来解决
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在原来的代码里,删除附件时会先在数据库里删除后向云端发起删除请求,所以就算抛出了异常还是会有文件遗失问题。如果想要通过抛出异常防止文件遗失,可能要先将这个顺序改过来?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那对于这个方法可以在进入时查询一下oss bucket中该文件是否存在,不存在直接return即可,存在再删除,这样就不需要去改原来的顺序问题了,因为issue的问题就是通过其他途径删除了bucket中的该文件导致抛出异常,如果文件不存在直接return即只有数据库被删除是合理的