更新日志
🚀 核心优化
- ⚡ 减少重复写入:探测阶段只保存 MediaStreams,不保存 Item 元数据,避免与 Jellyfin 元数据重置产生竞态条件
- ⚡ 简化恢复逻辑:ItemUpdateListener 只恢复 Size、Container、RunTimeTicks(Jellyfin 不会重置 MediaStreams)
- ⚡ 简化缓存结构:只保留必要字段(Size、Container、RunTimeTicks),移除 TotalBitrate、Width、Height(已在 MediaStreams 中)
🔧 代码改进
- 🏗️ 职责分离:探测只负责获取和缓存,恢复只负责从缓存恢复
- 🏗️ 移除冗余代码:删除不再使用的
SaveItemWithRetryAsync方法 - 🏗️ 依赖简化:ItemUpdateListener 移除
IMediaStreamRepository依赖
🚨 关键修复
- 🛡️ 并发安全:移除
SemaphoreSlim运行时热替换逻辑,避免并发控制失效(MaxConcurrentExtract 需重启生效) - 🔧 Dispose 死锁修复:改用
Task.WhenAny实现异步超时等待,避免同步阻塞导致的潜在死锁 - 🔧 任务管理优化:
ConcurrentBag<Task>改为ConcurrentDictionary<Guid, Task>,复用 ID 作为防重键
💡 其他改进
- 🔧 配置线程安全:
_config字段声明为volatile,确保多线程读取安全 - 🔧 进度报告:添加
Math.Min防止进度超过 100% - 🔧 日志格式统一:
LocalizationManager日志格式统一为结构化日志 - 🏗️ 代码复用优化:提取通用验证方法和处理核心方法
Update Log
🚀 Core Optimizations
- ⚡ Reduced Redundant Writes: During the probing phase, only MediaStreams are saved; Item metadata is not saved to avoid race conditions with Jellyfin's metadata reset.
- ⚡ Simplified Recovery Logic: The ItemUpdateListener now only restores Size, Container, and RunTimeTicks (Jellyfin does not reset MediaStreams).
- ⚡ Simplified Cache Structure: Only necessary fields (Size, Container, RunTimeTicks) are retained. TotalBitrate, Width, and Height have been removed (as they are already in MediaStreams).
🔧 Code Improvements
- 🏗️ Separation of Responsibilities: Probing is only responsible for fetching and caching; recovery is only responsible for restoring from cache.
- 🏗️ Removed Redundant Code: Deleted the no longer used
SaveItemWithRetryAsyncmethod. - 🏗️ Dependency Simplification: ItemUpdateListener no longer depends on
IMediaStreamRepository.
🚨 Critical Fixes
- 🛡️ Concurrency Safety: Removed
SemaphoreSlimruntime hot-replacement logic to prevent concurrency control failures (MaxConcurrentExtract requires a restart to take effect). - 🔧 Dispose Deadlock Fix: Replaced with
Task.WhenAnyfor asynchronous timeout waiting, avoiding potential deadlocks caused by synchronous blocking. - 🔧 Task Management Optimization: Changed
ConcurrentBag<Task>toConcurrentDictionary<Guid, Task>, reusing ID as a duplicate prevention key.
💡 Other Improvements
- 🔧 Configuration Thread Safety: The
_configfield is declared asvolatileto ensure safe multi-threaded reads. - 🔧 Progress Reporting: Added
Math.Minto prevent progress from exceeding 100%. - 🔧 Log Format Standardization:
LocalizationManagerlog format unified to structured logging. - 🏗️ Code Reuse Optimization: Extracted common validation methods and core processing methods.