-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(drivers/alias): default sort & substitute link #1917
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
base: main
Are you sure you want to change the base?
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 fixes two behavioral issues in the alias driver: (1) applying default sorting based on backend driver settings when no explicit sort order is specified, and (2) implementing fallback logic to try alternative paths when link retrieval fails for one conflicting path.
Key Changes
- Added
getAllSortfunction to collect and unify sort settings from multiple storage backends - Modified
Listmethod to apply backend sorting when the alias driver has no explicit sort configuration - Refactored
Linkmethod to iterate through all files in BalancedObjs and retry on failure instead of using a single balanced path
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| drivers/alias/util.go | Adds new getAllSort function to collect sort preferences from multiple storages |
| drivers/alias/driver.go | Updates List to use default backend sorting and refactors Link to implement fallback logic for failed link retrievals |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| noExtractFolder = true | ||
| } | ||
| } | ||
| if !noSort && !noExtractFolder { |
Copilot
AI
Jan 7, 2026
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.
The early break condition is incorrect. The loop should only break when BOTH noSort and noExtractFolder are true, not when both are false. Currently, the loop breaks immediately after processing the first storage with OrderBy and ExtractFolder settings, preventing it from checking if other storages have conflicting settings. This should be changed to check if both flags are true.
| if !noSort && !noExtractFolder { | |
| if noSort && noExtractFolder { |
| } | ||
| if err != nil { | ||
| return nil, err | ||
| } |
Copilot
AI
Jan 7, 2026
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.
Potential nil pointer dereference. If all files in the BalancedObjs array are nil or all attempts to get a link fail, the code will reach line 318 with 'link' still being nil, causing a panic when dereferencing it. Add a check to ensure 'link' is not nil before dereferencing, or handle this edge case appropriately.
| } | |
| } | |
| if link == nil { | |
| return nil, errors.New("alias: no valid link obtained for balanced object") | |
| } |
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Description / 描述
修复
alias与过去不同的两个行为:Motivation and Context / 背景
How Has This Been Tested? / 测试
Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。