feat: report STRM tree batch progress

This commit is contained in:
ShukeBta
2026-07-02 21:48:53 +08:00
parent 87928cfa4d
commit 1afc69baa0
5 changed files with 30 additions and 10 deletions
+5 -1
View File
@@ -44,8 +44,10 @@ func (s *STRMService) GenerateFromTree(ctx context.Context, opts GenerateSTRMTre
}
}
result := &GenerateSTRMResult{LibraryID: provider, OutputDir: outputDir}
sources := collectSTRMTreeSources(opts)
result.Total = len(sources)
expectedFiles := make(map[string]struct{})
for _, source := range collectSTRMTreeSources(opts) {
for i, source := range sources {
select {
case <-ctx.Done():
return result, ctx.Err()
@@ -57,6 +59,8 @@ func (s *STRMService) GenerateFromTree(ctx context.Context, opts GenerateSTRMTre
}
result.addItem(item)
if strmTreeBatchLimitReached(result, opts.BatchLimit) {
result.Remaining = len(sources) - i - 1
result.BatchLimited = result.Remaining > 0
break
}
}