Skip to content

Conversation

@KirCute
Copy link
Member

@KirCute KirCute commented Jan 4, 2026

Description / 描述

修复alias与过去不同的两个行为:

  1. 当不指定排序方式时,使用后端驱动的排序方式进行排序,避免返回结果顺序随机变化。
  2. 当其中一个冲突路径获取 link 失败时,尝试使用其余冲突路径获取。

Motivation and Context / 背景

How Has This Been Tested? / 测试

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

@KirCute KirCute requested a review from j2rong4cn January 4, 2026 14:11
@KirCute KirCute added bug Module: Driver Driver-Related Issue/PR labels Jan 4, 2026
@xrgzs xrgzs requested a review from Copilot January 7, 2026 06:45
Copy link
Contributor

Copilot AI left a 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 getAllSort function to collect and unify sort settings from multiple storage backends
  • Modified List method to apply backend sorting when the alias driver has no explicit sort configuration
  • Refactored Link method 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 {
Copy link

Copilot AI Jan 7, 2026

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.

Suggested change
if !noSort && !noExtractFolder {
if noSort && noExtractFolder {

Copilot uses AI. Check for mistakes.
}
if err != nil {
return nil, err
}
Copy link

Copilot AI Jan 7, 2026

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.

Suggested change
}
}
if link == nil {
return nil, errors.New("alias: no valid link obtained for balanced object")
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Module: Driver Driver-Related Issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant