diff options
| author | Logan Douglas <42654828+JadedRain@users.noreply.github.com> | 2025-10-31 13:06:17 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-31 13:06:17 -0600 |
| commit | 490bf347cbdf8ec458996d09ba40651eb647b7b9 (patch) | |
| tree | 1bdad774667bf5e69f3fe7397a27f631a5ca617a /Emby.Server.Implementations/Chapters/ChapterManager.cs | |
| parent | fd6e48603bcf143a1bbc3b1bda26a8e1664f9379 (diff) | |
| parent | 23929a3e709f4324d49271c02b0b047e1149e860 (diff) | |
Merge branch 'jellyfin:master' into master
Diffstat (limited to 'Emby.Server.Implementations/Chapters/ChapterManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Chapters/ChapterManager.cs | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/Emby.Server.Implementations/Chapters/ChapterManager.cs b/Emby.Server.Implementations/Chapters/ChapterManager.cs index b4daa2a143..d09ed30ae3 100644 --- a/Emby.Server.Implementations/Chapters/ChapterManager.cs +++ b/Emby.Server.Implementations/Chapters/ChapterManager.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using System.Threading; @@ -224,7 +223,7 @@ public class ChapterManager : IChapterManager if (saveChapters && changesMade) { - _chapterRepository.SaveChapters(video.Id, chapters); + SaveChapters(video, chapters); } DeleteDeadImages(currentImages, chapters); @@ -235,7 +234,9 @@ public class ChapterManager : IChapterManager /// <inheritdoc /> public void SaveChapters(Video video, IReadOnlyList<ChapterInfo> chapters) { - _chapterRepository.SaveChapters(video.Id, chapters); + // Remove any chapters that are outside of the runtime of the video + var validChapters = chapters.Where(c => c.StartPositionTicks < video.RunTimeTicks).ToList(); + _chapterRepository.SaveChapters(video.Id, validChapters); } /// <inheritdoc /> @@ -251,23 +252,9 @@ public class ChapterManager : IChapterManager } /// <inheritdoc /> - public void DeleteChapterImages(Video video) + public async Task DeleteChapterDataAsync(Guid itemId, CancellationToken cancellationToken) { - var path = _pathManager.GetChapterImageFolderPath(video); - try - { - if (Directory.Exists(path)) - { - _logger.LogInformation("Removing chapter images for {Name} [{Id}]", video.Name, video.Id); - Directory.Delete(path, true); - } - } - catch (Exception ex) - { - _logger.LogWarning("Failed to remove chapter image folder for {Item}: {Exception}", video.Id, ex); - } - - _chapterRepository.DeleteChapters(video.Id); + await _chapterRepository.DeleteChaptersAsync(itemId, cancellationToken).ConfigureAwait(false); } private IReadOnlyList<string> GetSavedChapterImages(Video video, IDirectoryService directoryService) |
