Skip to content

feat(task-group): introduce TaskGroupCoordinator for coordinated task execution#721

Merged
PIKACHUIM merged 28 commits intoOpenListTeam:mainfrom
sevxn007:feat/task
Jul 24, 2025
Merged

feat(task-group): introduce TaskGroupCoordinator for coordinated task execution#721
PIKACHUIM merged 28 commits intoOpenListTeam:mainfrom
sevxn007:feat/task

Conversation

@sevxn007
Copy link
Copy Markdown
Member

@sevxn007 sevxn007 commented Jul 15, 2025

添加任务hook函数
添加批量任务完成后操作
移动操作改用复制任务

refactor(move): move use CopyTask
@SenkjM SenkjM requested a review from Copilot July 15, 2025 03:46

This comment was marked as outdated.

@sevxn007 sevxn007 changed the title feat(task): add task hook,batch task refactor(move): move use CopyTask feat(task): add task hook,batch task Jul 15, 2025
@j2rong4cn j2rong4cn marked this pull request as draft July 15, 2025 09:25
@j2rong4cn j2rong4cn marked this pull request as ready for review July 15, 2025 10:42
@j2rong4cn j2rong4cn marked this pull request as draft July 15, 2025 12:06
@j2rong4cn j2rong4cn assigned j2rong4cn and unassigned j2rong4cn Jul 15, 2025
@jyxjjj jyxjjj requested a review from Copilot July 16, 2025 12:26
Copy link
Copy Markdown
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 introduces a task lifecycle interface, adds a batch-task coordinator for registering hooks that run after all related tasks complete, refactors existing tasks (Move, Copy, Transfer, Upload, Download, Archive) to use the new lifecycle, and standardizes MIME detection using utils.GetMimeType.

  • Added task.Lifecycle interface and RunWithLifecycle to manage BeforeRun, RunCore, and AfterRun hooks.
  • Implemented BatchTaskCoordinator in internal/task/batch_task and wired it into file and offline-download operations to perform refresh/remove logic after batches finish.
  • Replaced ad-hoc mime.TypeByExtension calls with utils.GetMimeType in WebDAV and HTTP serving code.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/webdav/prop.go Replaced mime.TypeByExtension with utils.GetMimeType
server/handles/fsmanage.go Updated MoveWithTaskAndValidation call to match new signature
internal/task/hook.go Added Lifecycle interface and RunWithLifecycle
internal/task/batch_task/refresh.go Created refreshAndRemove batch‐finish hook
internal/task/batch_task/batch_task.go Introduced BatchTaskCoordinator
internal/offline_download/tool/transfer.go Integrated batch hooks into transfer tasks
internal/offline_download/tool/download.go Integrated batch hooks into download tasks
internal/offline_download/tool/add.go Propagated ApiUrl and batch hooks into AddURL tasks
internal/net/serve.go Switched HTTP serving to use utils.GetMimeType
internal/fs/put.go Refactored upload tasks to lifecycle and added batch hooks
internal/fs/move.go Refactored move tasks to lifecycle and integrated batch hooks
internal/fs/fs.go Updated MoveWithTaskAndValidation signature
internal/fs/copy.go Refactored copy tasks to lifecycle and added batch hooks
internal/fs/archive.go Integrated batch hooks into archive download/upload tasks
internal/bootstrap/batch_task.go Initialized batch‐task hook in bootstrap
cmd/server.go Registered batch‐task hook on server startup
Comments suppressed due to low confidence (3)

internal/task/batch_task/batch_task.go:19

  • Typo in function name: NewBatchTasCoordinator should be spelled NewBatchTaskCoordinator for clarity and consistency.
func NewBatchTasCoordinator(name string) *BatchTaskCoordinator {

internal/task/batch_task/batch_task.go:33

  • Consider adding unit tests for BatchTaskCoordinator methods (AddTask, MarkTaskFinish, SetAllFinishHook) to verify that payloads are tracked correctly and hooks fire when counts reach zero.
func (bt *BatchTaskCoordinator) AddTask(targetPath string, payload any) {

server/handles/fsmanage.go:104

  • The original validateExistence flag (!req.Overwrite) was removed here, changing overwrite behavior. Reintroduce an explicit overwrite parameter or restore the previous call signature to preserve intended semantics.
		t, err := fs.MoveWithTaskAndValidation(c.Request.Context(), stdpath.Join(srcDir, name), dstDir, len(req.Names) > i+1)

@sevxn007 sevxn007 marked this pull request as ready for review July 17, 2025 01:49
@j2rong4cn j2rong4cn marked this pull request as draft July 17, 2025 05:54
@j2rong4cn j2rong4cn marked this pull request as ready for review July 19, 2025 07:30
@j2rong4cn j2rong4cn marked this pull request as draft July 19, 2025 07:31
@j2rong4cn j2rong4cn marked this pull request as ready for review July 19, 2025 07:50
@j2rong4cn j2rong4cn changed the title feat(task): add task hook,batch task feat(task-group): introduce TaskGroupCoordinator for coordinated task execution Jul 19, 2025
@j2rong4cn
Copy link
Copy Markdown
Member

没活了,就这样吧,再测试测试 没bug的话就合了

@sevxn007
Copy link
Copy Markdown
Member Author

没活了,就这样吧,再测试测试 没bug的话就合了

本地测试了下,没发现明显问题

@PIKACHUIM
Copy link
Copy Markdown
Member

@Seven66677731 @j2rong4cn 辛苦看下冲突

@sevxn007
Copy link
Copy Markdown
Member Author

@Seven66677731 @j2rong4cn 辛苦看下冲突

#592 功能重复了,j2rong4cn 已经Revert,这个没啥问题了可以直接合并了

@PIKACHUIM PIKACHUIM merged commit e93ab76 into OpenListTeam:main Jul 24, 2025
12 checks passed
@xrgzs xrgzs mentioned this pull request Jul 24, 2025
8 tasks
Suyunmeng pushed a commit that referenced this pull request Jul 30, 2025
… execution (#721)

* feat(task): add task hook,batch task
refactor(move): move use CopyTask

* Update internal/task/batch_task/refresh.go

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Seven <[email protected]>

* fix: upload task allFinish judge

* Update internal/task/batch_task/refresh.go

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Seven <[email protected]>

* feat: enhance concurrency safety

* 优化代码

* 解压缩

* 修复死锁

* refactor(move): move as task

* 重构,优化

* .

* 优化,修复bug

* .

* 修复bug

* feat: add task retry judge

* 代理Task.SetState函数来判断Task的生命周期

* chore: use OnSucceeded、OnFailed、OnBeforeRetry functions

* 优化

* 优化,去除重复代码

* .

* 优化

* .

* webdav

* Revert "fix(fs):After the file is copied or moved, flush the cache of the directory that was copied or moved to."

This reverts commit 5f03edd.

---------

Signed-off-by: Seven <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: j2rong4cn <[email protected]>
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.

[BUG] 跨盘移动文件夹时,移动完成后,源文件夹没有删除

5 participants