-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
refactor(op): remove automatic Path assignment #1734
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
|
如果跨多个组件,请使用主要组件作为前缀,并在标题中枚举、描述中说明。 |
Path和Id只在驱动内使用,不应由op.List设置Path
当List方法加载二级目录时,若使用的是Id,应对使用driver.RootID
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 refactors path handling by removing automatic path assignment from the op layer and delegating this responsibility to individual driver implementations. The changes simplify the architecture by making path management explicit at the driver level.
- Removed automatic path assignment logic from
internal/op/fs.goandinternal/op/archive.go - Removed
IdandPathfields from API response structures (ObjResp) - Updated all storage drivers to explicitly set the
Pathfield when creating objects
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/op/fs.go | Removed automatic path assignment loop; moved root folder check before Getter interface for better efficiency |
| internal/op/archive.go | Removed path assignment logic and simplified function signatures to remove unused return values |
| server/handles/fsread.go | Removed Id and Path fields from ObjResp struct and response objects |
| server/handles/sharing.go | Removed Id and Path fields from responses; improved variable scoping for fakePath |
| drivers/*/driver.go (multiple) | Added explicit Path field assignment using path.Join(dir.GetPath(), obj.Name) pattern |
| drivers/github_releases/meta.go | Changed from RootID to RootPath interface |
| drivers/cnb_releases/meta.go | Changed from RootPath to RootID interface; removed DefaultRoot config field |
| drivers/azure_blob/meta.go | Changed from RootID to RootPath; removed custom GetRootId() method |
| drivers/strm/util.go | Fixed variable naming to use SourceExt instead of Ext for correct extension handling |
| drivers/seafile/driver.go | Simplified nested conditional logic for root directory handling |
| drivers/smb/driver.go | Changed from ObjThumb wrapper to direct Object instantiation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
KirCute
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.
正确的,很久之前就想吐槽这件事了。
另外我个人建议直接删除model.Obj的GetPath和GetID方法,新增model.ObjWithPath(不一定叫这个,我觉得不好听)接口实现Obj、GetPath和GetID,op层和上层使用model.Obj交互,和驱动使用model.ObjWithPath交互,有效避免在开发上层模块时误把GetPath的返回结果当全局路径使用的问题。
要加很多类型断言,还是算了,改的地方太多 |
要加类型断言不就说明确实有更上层的模块使用了 |
另外pr搞吧 |
Description / 描述
当List方法加载二级目录时,若使用的是Id,应对使用driver.RootID
Motivation and Context / 背景
How Has This Been Tested? / 测试
Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。