-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor(fs): batch remove and rename #1110
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?
refactor(fs): batch remove and rename #1110
Conversation
Signed-off-by: jenken827 <jenken827@gmail.com>
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 file operations to support native batch rename and remove operations instead of using inefficient loops, while centralizing path validation and authentication logic in middleware.
- Adds support for native batch rename and batch remove operations through new driver interfaces
- Consolidates duplicate path parsing and authentication code into reusable middleware functions
- Implements batch operations for Baidu Netdisk and 123 Open cloud storage drivers
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
server/router.go | Adds middleware to batch rename and remove endpoints |
server/middlewares/fsup.go | Removes old upload middleware (replaced by generic fs middleware) |
server/middlewares/fs.go | Creates new centralized middleware for file operations with path validation and authentication |
server/handles/fsmanage.go | Refactors remove handler to use batch operations and middleware context |
server/handles/fsbatch.go | Simplifies batch rename handler using new middleware and batch operations |
internal/op/fs.go | Adds BatchRemove function supporting native batch operations |
internal/model/obj.go | Defines new data structures for batch operations (IDName, RenameObj) |
internal/fs/fs.go | Implements BatchRename and BatchRemove functions with fallback to individual operations |
internal/driver/driver.go | Adds BatchRename and BatchRemove interfaces |
internal/conf/const.go | Adds StorageKey constant for context storage |
drivers/baidu_netdisk/driver.go | Implements BatchRename and BatchRemove for Baidu Netdisk |
drivers/123_open/util.go | Adds batch rename utility and modifies trash function for batch operations |
drivers/123_open/driver.go | Implements BatchRename and BatchRemove for 123 Open with chunking support |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
很多网盘原生支持批量重命名和删除,但是目前openlist对于这两种操作是通过循环调用单次重命名和删除实现的,量大时效率非常低下,还容易导致失败(有些api有调用频率限制)。
修改点如下:
1.支持了原生批量重命名和删除
2.文件相关操作有大量重复的对于path的解析及鉴权代码,优化集中到中间件中
3.修复在批量重命名选择序列模式(第二个模式)时,如果文件本身没有扩展名,重命名后会多出一个"."的问题(前端)
Frontend: OpenListTeam/OpenList-Frontend#174