Enhance CleanupManualLeftoversAsync to remove subtitles from nested folders and empty directories
ci / build-backend (push) Successful in 2m50s
ci / build-frontend (push) Successful in 1m7s
ci / tests (push) Successful in 3m1s
ci / sonar (push) Successful in 6m15s

Updated the CleanupManualLeftoversAsync method to improve its functionality by allowing it to delete subtitle files located in nested directories and remove empty directories after the last episode is processed. Introduced a CompanionMatcher class to accurately identify companion files based on naming conventions. Added integration tests to verify the new cleanup behavior, ensuring that only relevant files are removed while preserving necessary content.
This commit is contained in:
Leonid Pershin
2026-07-27 08:57:11 +03:00
parent 0fd4e762f4
commit f22aee4685
3 changed files with 149 additions and 28 deletions
@@ -35,9 +35,10 @@ public interface IMediaStorage
IReadOnlyList<ManualInboxFile> ListManualInbox(int max);
/// <summary>
/// Убирает то, что осталось в <c>manual/</c> рядом с забранным файлом: спутники с тем же именем
/// и другим расширением (субтитры, nfo, обложка) и опустевший каталог. Другие видеофайлы
/// не трогает — рядом может лежать следующая серия.
/// Убирает то, что осталось в <c>manual/</c> от забранного файла: спутники с тем же именем
/// и другим расширением (субтитры, nfo, обложка), файлы того же эпизода в соседних подпапках
/// (<c>subs_ru</c>, <c>Subtitles</c>) и опустевшие каталоги вверх до корня <c>manual/</c>.
/// Другие видеофайлы не трогает — рядом может лежать следующая серия или иная версия.
/// </summary>
Task CleanupManualLeftoversAsync(string relativePath, CancellationToken cancellationToken);