mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-07 22:06:38 +08:00
fix cloud library scale and playback compatibility
Root cause: display-only cloud library filtering was reused by scan jobs, merged cloud mounts could be skipped, and OpenList listing relied on WebDAV/first-page behavior that could cap huge directories around 100 items. Cloud scans also let new items consume probe budget before existing rows with missing track/artwork metadata.\n\nChanges:\n- split display filtering from scannable cloud filtering so merged cloud mounts still scan\n- add OpenList API pagination with WebDAV fallback\n- prioritize existing cloud media missing metadata before new imports\n- restrict automatic cloud sync to one successful 19:00-21:00 daily window and keep manual scan immediate\n- disable startup cloud full-scan by default, with an explicit opt-in setting\n- improve Emby/cloud playback compatibility and cache/search/test coverage from the continued work
This commit is contained in:
@@ -73,7 +73,8 @@ type Container struct {
|
||||
Device *DeviceService
|
||||
|
||||
stopCtx context.Context
|
||||
stopCancel context.CancelFunc}
|
||||
stopCancel context.CancelFunc
|
||||
}
|
||||
|
||||
// New 构建服务容器。
|
||||
func New(cfg *config.Config, log *zap.Logger, repos *repository.Container) *Container {
|
||||
@@ -116,6 +117,7 @@ func New(cfg *config.Config, log *zap.Logger, repos *repository.Container) *Cont
|
||||
storageCfg := NewStorageConfigService(log, repos, crypto)
|
||||
strmSvc := NewSTRMService(log, repos, cfg)
|
||||
scanner.SetStorageConfig(storageCfg)
|
||||
emby.SetCloudProbe(storageCfg, probe)
|
||||
downloadClients := NewDownloadClientService(log, repos)
|
||||
assistant := NewAssistantService(log, repos, ai)
|
||||
douban := NewDoubanProvider(cfg, log)
|
||||
@@ -239,6 +241,7 @@ func (c *Container) Boot() {
|
||||
if err := c.NormalizeCloudLibraryTypes(c.stopCtx); err != nil {
|
||||
c.Log.Warn("normalize cloud library types failed", zap.Error(err))
|
||||
}
|
||||
go c.warmMediaSearchIndex(c.stopCtx)
|
||||
|
||||
// 加载所有已配置的下载客户端
|
||||
if err := c.DownloadMgr.LoadAll(c.stopCtx); err != nil {
|
||||
@@ -261,6 +264,39 @@ func (c *Container) Boot() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Container) warmMediaSearchIndex(ctx context.Context) {
|
||||
if c == nil || c.Repo == nil || c.Repo.Media == nil {
|
||||
return
|
||||
}
|
||||
const batchSize = 1000
|
||||
const pause = 100 * time.Millisecond
|
||||
total := int64(0)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
n, err := c.Repo.Media.BackfillSearchIndex(ctx, batchSize)
|
||||
if err != nil {
|
||||
c.Log.Debug("media search index warmup stopped", zap.Error(err))
|
||||
return
|
||||
}
|
||||
if n == 0 {
|
||||
if total > 0 {
|
||||
c.Log.Info("media search index warmed", zap.Int64("indexed", total))
|
||||
}
|
||||
return
|
||||
}
|
||||
total += n
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(pause):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Container) NormalizeCloudLibraryTypes(ctx context.Context) error {
|
||||
if c == nil || c.Repo == nil || c.Repo.Library == nil || c.Repo.DB == nil {
|
||||
return nil
|
||||
@@ -340,9 +376,3 @@ func (c *Container) Close() {
|
||||
|
||||
// unused guard
|
||||
var _ = time.Now
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user