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
Refactor #6
Refactor #6
Changes from 6 commits
5ee1e71
c4abf4e
cb916c6
e590652
7a818cc
02489aa
9a33cdf
bba6bd2
98e43f5
b3e722d
fe03004
c9ea5e5
813a50a
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.
这里请勿调整,按原来的实现。
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.
分块和不分块这两部分逻辑比较独立,没有必要用 if else 区别。
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.
另外,eventbus.Publish(eventbus.EvtIndexUpsertFile, context, count, total) 和 putFileErr := repo.store.PutFile(file) 的顺序也不要调整。
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.
在同一个函数里,不使用 if else ,没法控制不执行在后面分块的逻辑,除非把整个复用的部分全分别塞在两部分逻辑里,使用提前返回控制。
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.
这里没有必要抽取变量了,直接条件判断。
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.
这个函数的本意是判断文件是否更新,虽然为了跟之前的代码保持一致,在错误里也携带了相关信息,但连 bool 也不带感觉语义怎么看都不太合适……
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.
主要是update是返回值啊……不抽取变量的话,这个函数不就变成一个只返回error的函数了?
要不我把ErrIndexFileChanged交个上一层的putFileChunks进行生成?checkFileIfUpdate 只产生 os.Stat 的报错。
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.
你外面也没有用到这个返回值啊:
ErrIndexFileChanged 原本就是在 putFileChunks 里的……
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.
嗯,那我就改成ErrIndexFileChanged在putFileChunks 里,不在check 函数里了
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.
已修改