< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.Year
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/Year.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 33
Coverable lines: 33
Total lines: 129
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/16/2026 - 12:15:55 AM Line coverage: 0% (0/35) Branch coverage: 0% (0/10) Total lines: 13210/29/2026 - 12:17:11 AM Line coverage: 0% (0/33) Branch coverage: 0% (0/10) Total lines: 129 5/16/2026 - 12:15:55 AM Line coverage: 0% (0/35) Branch coverage: 0% (0/10) Total lines: 13210/29/2026 - 12:17:11 AM Line coverage: 0% (0/33) Branch coverage: 0% (0/10) Total lines: 129

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_SupportsAncestors()100%210%
get_SupportsPeople()100%210%
get_ContainingFolderPath()100%210%
CanDelete()100%210%
GetUserDataKeys()100%210%
GetDefaultPrimaryImageAspectRatio()100%210%
IsSaveLocalMetadataEnabled()100%210%
GetTaggedItems(...)0%620%
GetYearValue()0%620%
GetPath(...)100%210%
GetPath(...)0%620%
GetRebasedPath()100%210%
RequiresRefresh()0%620%
BeforeMetadataRefresh(...)0%620%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/Year.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Globalization;
 8using System.Text.Json.Serialization;
 9using Microsoft.Extensions.Logging;
 10
 11namespace MediaBrowser.Controller.Entities
 12{
 13    /// <summary>
 14    /// Class Year.
 15    /// </summary>
 16    [Common.RequiresSourceSerialisation]
 17    public class Year : BaseItem, IItemByName
 18    {
 19        [JsonIgnore]
 020        public override bool SupportsAncestors => false;
 21
 22        [JsonIgnore]
 023        public override bool SupportsPeople => false;
 24
 25        /// <summary>
 26        /// Gets the folder containing the item.
 27        /// If the item is a folder, it returns the folder itself.
 28        /// </summary>
 29        /// <value>The containing folder path.</value>
 30        [JsonIgnore]
 031        public override string ContainingFolderPath => Path;
 32
 33        public override bool CanDelete()
 34        {
 035            return false;
 36        }
 37
 38        public override List<string> GetUserDataKeys()
 39        {
 040            var list = base.GetUserDataKeys();
 41
 042            list.Insert(0, "Year-" + Name);
 043            return list;
 44        }
 45
 46        public override double GetDefaultPrimaryImageAspectRatio()
 47        {
 048            double value = 2;
 049            value /= 3;
 50
 051            return value;
 52        }
 53
 54        public override bool IsSaveLocalMetadataEnabled()
 55        {
 056            return true;
 57        }
 58
 59        public IReadOnlyList<BaseItem> GetTaggedItems(InternalItemsQuery query)
 60        {
 061            if (!int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
 62            {
 063                return new List<BaseItem>();
 64            }
 65
 066            query.Years = new[] { year };
 67
 068            return LibraryManager.GetItemList(query);
 69        }
 70
 71        public int? GetYearValue()
 72        {
 073            if (int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
 74            {
 075                return year;
 76            }
 77
 078            return null;
 79        }
 80
 81        public static string GetPath(string name)
 82        {
 083            return GetPath(name, true);
 84        }
 85
 86        public static string GetPath(string name, bool normalizeName)
 87        {
 088            var validName = normalizeName ? GetItemByNameFolderName(name) : name;
 89
 090            return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.YearPath, validName);
 91        }
 92
 93        private string GetRebasedPath()
 94        {
 095            return GetPath(System.IO.Path.GetFileName(Path), false);
 96        }
 97
 98        public override bool RequiresRefresh()
 99        {
 0100            var newPath = GetRebasedPath();
 0101            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 102            {
 0103                Logger.LogDebug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath);
 0104                return true;
 105            }
 106
 0107            return base.RequiresRefresh();
 108        }
 109
 110        /// <summary>
 111        /// This is called before any metadata refresh and returns true if changes were made.
 112        /// </summary>
 113        /// <param name="replaceAllMetadata">Whether to replace all metadata.</param>
 114        /// <returns>true if the item has change, else false.</returns>
 115        public override bool BeforeMetadataRefresh(bool replaceAllMetadata)
 116        {
 0117            var hasChanges = base.BeforeMetadataRefresh(replaceAllMetadata);
 118
 0119            var newPath = GetRebasedPath();
 0120            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 121            {
 0122                Path = newPath;
 0123                hasChanges = true;
 124            }
 125
 0126            return hasChanges;
 127        }
 128    }
 129}