-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(onedrive_shareurl): Reduce temporary file errors #1686
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
Conversation
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.
Pull request overview
This PR improves header refresh handling in the OneDrive sharelink driver to reduce temporary file errors caused by expired authentication headers. When download tasks fail, the code now proactively refreshes cached headers instead of waiting for the periodic refresh cycle.
Key changes:
- Introduced thread-safe header management with
sync.RWMutexand singleflight pattern to prevent concurrent refresh storms - Reduced header TTL from 30 minutes to 25 minutes and added automatic refresh logic in the
Link()method - Added
RangeReaderwith retry-on-failure logic that automatically refreshes headers when encountering invalid responses
Comments suppressed due to low confidence (7)
drivers/onedrive_sharelink/driver.go:1
- Direct access to
d.Headerswithout lock protection. This should used.headerSnapshot()to avoid potential race conditions with concurrent header updates from the cron job or refresh operations.
package onedrive_sharelink
drivers/onedrive_sharelink/driver.go:1
- Direct access to
d.Headerswithout lock protection at lines 202 and 211. These accesses should used.headerSnapshot()to prevent race conditions during concurrent header updates.
package onedrive_sharelink
drivers/onedrive_sharelink/driver.go:1
- Direct access to
d.Headerswithout lock protection at lines 202 and 211. These accesses should used.headerSnapshot()to prevent race conditions during concurrent header updates.
package onedrive_sharelink
drivers/onedrive_sharelink/driver.go:1
- Direct writes to
d.Headersat lines 225, 302, 332, and 347 bypass the new thread-safestoreHeaders()method. These should be updated to used.storeHeaders()or preferably replaced with calls tod.refreshHeaders(ctx)to ensure thread safety and consistency.
package onedrive_sharelink
drivers/onedrive_sharelink/driver.go:1
- Direct writes to
d.Headersat lines 225, 302, 332, and 347 bypass the new thread-safestoreHeaders()method. These should be updated to used.storeHeaders()or preferably replaced with calls tod.refreshHeaders(ctx)to ensure thread safety and consistency.
package onedrive_sharelink
drivers/onedrive_sharelink/driver.go:1
- Direct writes to
d.Headersat lines 225, 302, 332, and 347 bypass the new thread-safestoreHeaders()method. These should be updated to used.storeHeaders()or preferably replaced with calls tod.refreshHeaders(ctx)to ensure thread safety and consistency.
package onedrive_sharelink
drivers/onedrive_sharelink/driver.go:1
- Direct writes to
d.Headersat lines 225, 302, 332, and 347 bypass the new thread-safestoreHeaders()method. These should be updated to used.storeHeaders()or preferably replaced with calls tod.refreshHeaders(ctx)to ensure thread safety and consistency.
package onedrive_sharelink
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ILoveScratch2
left a comment
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.
LGTM
Description / 描述
当任务失败时,刷新缓存的headers,来防止过久的等待刷新
Motivation and Context / 背景
频繁报错
%!w(<nil>); CreateTempFile failed, size mismatch: 570 != 10480任务报错失败后,重试时大概率会出现同样的情况,
How Has This Been Tested? / 测试
Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。