Skip to content

Conversation

@j2rong4cn
Copy link
Member

@j2rong4cn j2rong4cn commented Nov 29, 2025

Description / 描述

  • api不再返回文件对象的Path和Id,对于客户端来说没什么用处,徒增数据传输量
  • 移除op.List的自动设置Path,Path和Id只在驱动内使用,不应由op.List设置Path
  • cnb_releases:将 Addition 结构体中的 RootPath 字段为 RootID
    当List方法加载二级目录时,若使用的是Id,应对使用driver.RootID

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).
    我已相应更新了相关仓库(若适用)。

@github-actions
Copy link

⚠️ PR 标题需以 feat(): , docs(): , fix(): , style(): , refactor(): , chore(): 其中之一开头,例如:feat(component): 新增功能
⚠️ The PR title must start with feat(): , docs(): , fix(): , style(): , or refactor(): , chore(): . For example: feat(component): add new feature.

如果跨多个组件,请使用主要组件作为前缀,并在标题中枚举、描述中说明。
If it spans multiple components, use the main component as the prefix and enumerate in the title, describe in the body.

Path和Id只在驱动内使用,不应由op.List设置Path
当List方法加载二级目录时,若使用的是Id,应对使用driver.RootID
@j2rong4cn j2rong4cn changed the title feat: add object masking functionality refactor(op): remove automatic Path assignment Dec 2, 2025
@j2rong4cn j2rong4cn marked this pull request as ready for review December 2, 2025 14:09
Copilot finished reviewing on behalf of j2rong4cn December 2, 2025 14:14
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 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.go and internal/op/archive.go
  • Removed Id and Path fields from API response structures (ObjResp)
  • Updated all storage drivers to explicitly set the Path field 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.

Copy link
Member

@KirCute KirCute left a comment

Choose a reason for hiding this comment

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

正确的,很久之前就想吐槽这件事了。

另外我个人建议直接删除model.ObjGetPathGetID方法,新增model.ObjWithPath(不一定叫这个,我觉得不好听)接口实现ObjGetPathGetIDop层和上层使用model.Obj交互,和驱动使用model.ObjWithPath交互,有效避免在开发上层模块时误把GetPath的返回结果当全局路径使用的问题。

@j2rong4cn
Copy link
Member Author

建议直接删除model.ObjGetPathGetID方法

要加很多类型断言,还是算了,改的地方太多

@KirCute
Copy link
Member

KirCute commented Dec 2, 2025

要加很多类型断言,还是算了,改的地方太多

要加类型断言不就说明确实有更上层的模块使用了GetPath,不就说明上层的模块是有bug的

@j2rong4cn j2rong4cn merged commit 96cd714 into main Dec 2, 2025
12 checks passed
@j2rong4cn
Copy link
Member Author

要加很多类型断言,还是算了,改的地方太多

要加类型断言不就说明确实有更上层的模块使用了GetPath,不就说明上层的模块是有bug的

另外pr搞吧

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants