< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Library.VersionResumeData
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Library/VersionResumeData.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 41
Line coverage: 100%
Branch coverage
85%
Covered branches: 12
Total branches: 14
Branch coverage: 85.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 7/6/2026 - 12:16:28 AM Line coverage: 100% (7/7) Branch coverage: 85.7% (12/14) Total lines: 41 7/6/2026 - 12:16:28 AM Line coverage: 100% (7/7) Branch coverage: 85.7% (12/14) Total lines: 41

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ApplyTo(...)85.71%1414100%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Library/VersionResumeData.cs

#LineLine coverage
 1using System;
 2using MediaBrowser.Controller.Entities;
 3using MediaBrowser.Model.Dto;
 4
 5namespace MediaBrowser.Controller.Library
 6{
 7    /// <summary>
 8    /// The user data of the most recently played alternate version that should drive the completion state of a multi-ve
 9    /// </summary>
 10    /// <param name="VersionId">The id of the version that owns <paramref name="UserData"/>.</param>
 11    /// <param name="UserData">The resume version's user data.</param>
 12    public record VersionResumeData(Guid VersionId, UserItemData UserData)
 13    {
 14        /// <summary>
 15        /// Merges the most recently played version's completion state into the supplied user data dto.
 16        /// Completion (played) propagates to the primary. An in-progress resume position stays on the version
 17        /// that owns it, which is surfaced directly (e.g. in resume queries) so that playback always targets
 18        /// the correct version rather than resuming the primary at another version's offset. When the movie was
 19        /// finished on a different version, the primary's own stale resume position is cleared so it does not
 20        /// render as "watched and resumable" at the same time.
 21        /// </summary>
 22        /// <param name="dto">The user data dto to update.</param>
 23        public void ApplyTo(UserItemDataDto dto)
 24        {
 425            dto.Played = dto.Played || UserData.Played;
 26
 427            if ((UserData.LastPlayedDate ?? DateTime.MinValue) > (dto.LastPlayedDate ?? DateTime.MinValue))
 28            {
 329                dto.LastPlayedDate = UserData.LastPlayedDate;
 30            }
 31
 32            // A different version was finished (played, no resume position of its own) and is the most
 33            // recently played: the whole movie is watched.
 434            if (!VersionId.Equals(dto.ItemId) && UserData.Played && UserData.PlaybackPositionTicks <= 0)
 35            {
 136                dto.PlaybackPositionTicks = 0;
 137                dto.PlayedPercentage = null;
 38            }
 439        }
 40    }
 41}