Skip to content

优化缓存调用逻辑 #512

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

Merged
merged 6 commits into from
May 28, 2021
Merged

优化缓存调用逻辑 #512

merged 6 commits into from
May 28, 2021

Conversation

yinxulai
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented May 24, 2021

Codecov Report

Merging #512 (203a2ef) into master (71b1482) will increase coverage by 0.21%.
The diff coverage is 100.00%.

❗ Current head 203a2ef differs from pull request most recent head d3d9434. Consider uploading reports for the commit d3d9434 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #512      +/-   ##
==========================================
+ Coverage   72.24%   72.46%   +0.21%     
==========================================
  Files          20       20              
  Lines        1081     1086       +5     
  Branches      208      207       -1     
==========================================
+ Hits          781      787       +6     
+ Misses        300      299       -1     
Impacted Files Coverage Δ
src/upload/base.ts 82.72% <100.00%> (+0.15%) ⬆️
src/upload/resume.ts 94.28% <100.00%> (+1.21%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 71b1482...d3d9434. Read the comment docs.

Copy link
Collaborator

@lzfee0227 lzfee0227 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getProgressInfoItem 作为 resume 独有的东西
为什么实现在 base 里?

if (info) {
info.fromCache = false
}
if (info) { info.fromCache = false }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么越改越差?
不管 lint 是否正常,这是明确不推荐的行为

Copy link
Collaborator Author

@yinxulai yinxulai May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint 通过,合理

image

@lzfee0227
Copy link
Collaborator

NIP:
既然 getProgressInfoItem 用于计算 total 那么它有 fromCache 是稍微有点不太好的
因为这是 chunk 的专有概念

@yinxulai
Copy link
Collaborator Author

getProgressInfoItem 作为 resume 独有的东西
为什么实现在 base 里?

getProgressInfoItemresume 独有

this.logger.info(`upload part ${index}.`, info)

const shouldCheckMD5 = this.config.checkByMD5
const reuseSaved = () => {
info.fromCache = true
this.uploadedList[index] = info
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实做了这件事之后,fromCache 确实是有可能存进缓存的
只不过在 reuse 前,它不进去,或者进去也变成了 false
但是 reuse 一次之后,就变成了 true
这样不太好

@@ -239,6 +257,13 @@ export default class Resume extends Base {
return utils.createLocalKey(this.file.name, this.key, this.file.size)
}

private updateLocalCache() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问个问题,如果有 10 个分片,
如果第一次上传,传成功了 5 个分片的时候,然后关了网页
然后再打开页面上传,第 1 个分片上传成功,然后网络请求失败导致其他分片全部失败了
这时候重新上传,是不是 2~5 这几个本来可以复用的分片就废了?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huangbinjie dart sdk 是怎样的

lzfee0227
lzfee0227 previously approved these changes May 28, 2021
Copy link
Collaborator

@lzfee0227 lzfee0227 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
版本号?

Copy link
Collaborator

@lzfee0227 lzfee0227 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm+2

@yinxulai yinxulai merged commit 3012014 into qiniu:master May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants