< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.Person
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/Person.cs
Line coverage
27%
Covered lines: 11
Uncovered lines: 29
Coverable lines: 40
Total lines: 157
Line coverage: 27.5%
Branch coverage
35%
Covered branches: 5
Total branches: 14
Branch coverage: 35.7%
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: 31.7% (13/41) Branch coverage: 35.7% (5/14) Total lines: 1497/22/2026 - 12:16:22 AM Line coverage: 30.9% (13/42) Branch coverage: 35.7% (5/14) Total lines: 16010/29/2026 - 12:17:11 AM Line coverage: 27.5% (11/40) Branch coverage: 35.7% (5/14) Total lines: 157 5/16/2026 - 12:15:55 AM Line coverage: 31.7% (13/41) Branch coverage: 35.7% (5/14) Total lines: 1497/22/2026 - 12:16:22 AM Line coverage: 30.9% (13/42) Branch coverage: 35.7% (5/14) Total lines: 16010/29/2026 - 12:17:11 AM Line coverage: 27.5% (11/40) Branch coverage: 35.7% (5/14) Total lines: 157

Coverage delta

Coverage delta 4 -4

Metrics

File(s)

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

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Text.Json.Serialization;
 8using Jellyfin.Database.Implementations.Entities;
 9using Jellyfin.Extensions;
 10using MediaBrowser.Controller.Providers;
 11using Microsoft.Extensions.Logging;
 12
 13namespace MediaBrowser.Controller.Entities
 14{
 15    /// <summary>
 16    /// This is the full Person object that can be retrieved with all of it's data.
 17    /// </summary>
 18    [Common.RequiresSourceSerialisation]
 19    public class Person : BaseItem, IItemByName, IHasLookupInfo<PersonLookupInfo>
 20    {
 21        /// <summary>
 22        /// Gets the folder containing the item.
 23        /// If the item is a folder, it returns the folder itself.
 24        /// </summary>
 25        /// <value>The containing folder path.</value>
 26        [JsonIgnore]
 027        public override string ContainingFolderPath => Path;
 28
 29        /// <summary>
 30        /// Gets a value indicating whether to enable alpha numeric sorting.
 31        /// </summary>
 32        [JsonIgnore]
 033        public override bool EnableAlphaNumericSorting => false;
 34
 35        [JsonIgnore]
 036        public override bool SupportsPeople => false;
 37
 38        [JsonIgnore]
 039        public override bool SupportsAncestors => false;
 40
 41        public override List<string> GetUserDataKeys()
 42        {
 043            var list = base.GetUserDataKeys();
 44
 045            list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
 046            return list;
 47        }
 48
 49        public override string CreatePresentationUniqueKey()
 50        {
 051            return GetUserDataKeys()[0];
 52        }
 53
 54        public PersonLookupInfo GetLookupInfo()
 55        {
 056            return GetItemLookupInfo<PersonLookupInfo>();
 57        }
 58
 59        public override double GetDefaultPrimaryImageAspectRatio()
 60        {
 061            double value = 2;
 062            value /= 3;
 63
 064            return value;
 65        }
 66
 67        public IReadOnlyList<BaseItem> GetTaggedItems(InternalItemsQuery query)
 68        {
 069            query.PersonIds = new[] { Id };
 70
 071            return LibraryManager.GetItemList(query);
 72        }
 73
 74        public override bool CanDelete()
 75        {
 076            return false;
 77        }
 78
 79        /// <inheritdoc />
 80        /// <remarks>
 81        /// People don't carry the tags of the media they appear in, so the allowed tags check
 82        /// is skipped for them; otherwise no person would be visible to users with allowed tags configured.
 83        /// </remarks>
 84        public override bool IsVisible(User user, bool skipAllowedTagsCheck = false)
 85        {
 086            return base.IsVisible(user, true);
 87        }
 88
 89        public override bool IsSaveLocalMetadataEnabled()
 90        {
 091            return true;
 92        }
 93
 94        public static string GetPath(string name)
 95        {
 196            return GetPath(name, true);
 97        }
 98
 99        public static string GetPath(string name, bool normalizeName)
 100        {
 1101            var validFilename = normalizeName ? GetItemByNameFolderName(name) : name;
 102
 1103            string subFolderPrefix = null;
 104
 3105            foreach (char c in validFilename)
 106            {
 1107                if (char.IsLetterOrDigit(c))
 108                {
 1109                    subFolderPrefix = c.ToString();
 1110                    break;
 111                }
 112            }
 113
 1114            var path = ConfigurationManager.ApplicationPaths.PeoplePath;
 115
 1116            return string.IsNullOrEmpty(subFolderPrefix) ?
 1117                System.IO.Path.Combine(path, validFilename) :
 1118                System.IO.Path.Combine(path, subFolderPrefix, validFilename);
 119        }
 120
 121        private string GetRebasedPath()
 122        {
 0123            return GetPath(System.IO.Path.GetFileName(Path), false);
 124        }
 125
 126        public override bool RequiresRefresh()
 127        {
 0128            var newPath = GetRebasedPath();
 0129            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 130            {
 0131                Logger.LogDebug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath);
 0132                return true;
 133            }
 134
 0135            return base.RequiresRefresh();
 136        }
 137
 138        /// <summary>
 139        /// This is called before any metadata refresh and returns true or false indicating if changes were made.
 140        /// </summary>
 141        /// <param name="replaceAllMetadata"><c>true</c> to replace all metadata, <c>false</c> to not.</param>
 142        /// <returns><c>true</c> if changes were made, <c>false</c> if not.</returns>
 143        public override bool BeforeMetadataRefresh(bool replaceAllMetadata)
 144        {
 0145            var hasChanges = base.BeforeMetadataRefresh(replaceAllMetadata);
 146
 0147            var newPath = GetRebasedPath();
 0148            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 149            {
 0150                Path = newPath;
 0151                hasChanges = true;
 152            }
 153
 0154            return hasChanges;
 155        }
 156    }
 157}