Skip to content

feat(fs): support recursive file listing#2144

Open
varg1714 wants to merge 1 commit intoOpenListTeam:mainfrom
varg1714:feature/varg-0218-recursive-list
Open

feat(fs): support recursive file listing#2144
varg1714 wants to merge 1 commit intoOpenListTeam:mainfrom
varg1714:feature/varg-0218-recursive-list

Conversation

@varg1714
Copy link
Contributor

Description / 描述

增加递归扫描文件夹的按钮。

Motivation and Context / 背景

  • 通过递归扫描文件夹,以支持strm文件的自动生成
  • 通过递归扫描文件夹,以触发目录的缓存更新操作

当前在索引界面虽有手动触发扫描的方式,但使用较不方便,需要回到管理页面添加路径触发扫描。通过此功能,可以在目录即时触发扫描操作,借助异步扫描和扫描间隔的机制,避免风控和长时间的等待。

How Has This Been Tested? / 测试

本地测试strm文件的生成。

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

@varg1714 varg1714 changed the title feat(toolbar): support recursive file listing feat(fs): support recursive file listing Feb 18, 2026
@xrgzs xrgzs added enhancement Module: Server API and protocol changes labels Feb 19, 2026
@KirCute
Copy link
Member

KirCute commented Mar 10, 2026

我觉得不如把扫描加到右键菜单里,做成纯前端feat

思路留档:我在 #2210 提到可以把刮削功能做成中间件驱动,我将来还有一个写同步驱动的打算,如果这种具有主动触发功能的中间件驱动比较多的话,我觉得可以考虑在驱动管理页面给这些驱动加一个“扫描”按钮,这样既不用手动输入路径,也不会在右键菜单里加太多东西显得右键菜单很臃肿

Comment on lines +473 to +516
go func() {
ctx := context.Background()
ctx = context.WithValue(ctx, conf.UserKey, user)
ctx = context.WithValue(ctx, conf.MetaKey, meta)

queue := generic.NewQueue[string]()
queue.Push(reqPath)

visited := make(map[string]bool)

for queue.Len() > 0 {
currentPath := queue.Pop()

if visited[currentPath] {
continue
}
visited[currentPath] = true

objs, err := fs.List(ctx, currentPath, &fs.ListArgs{
Refresh: req.Refresh,
WithStorageDetails: false,
NoLog: true,
})
if err != nil {
log.Warnf("FsRecurseList: failed to list %s: %+v", currentPath, err)
continue
}

for _, obj := range objs {
if obj.IsDir() {
subPath := stdpath.Join(currentPath, obj.GetName())
if !visited[subPath] {
queue.Push(subPath)
}
}
}

if req.IntervalSec > 0 && queue.Len() > 0 {
time.Sleep(time.Duration(req.IntervalSec) * time.Second)
}
}

log.Infof("FsRecurseList: completed recursion for path %s", reqPath)
}()
Copy link
Member

Choose a reason for hiding this comment

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

或者把这一段换成op.RecursivelyList也行

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

Labels

enhancement Module: Server API and protocol changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants