< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.Person
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/Person.cs
Line coverage
30%
Covered lines: 13
Uncovered lines: 29
Coverable lines: 42
Total lines: 160
Line coverage: 30.9%
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/2/2026 - 12:12:50 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: 160 5/2/2026 - 12:12:50 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: 160

Coverage delta

Coverage delta 1 -1

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        {
 101            // Trim the period at the end because windows will have a hard time with that
 1102            var validFilename = normalizeName ?
 1103                FileSystem.GetValidFilename(name).Trim().TrimEnd('.') :
 1104                name;
 105
 1106            string subFolderPrefix = null;
 107
 3108            foreach (char c in validFilename)
 109            {
 1110                if (char.IsLetterOrDigit(c))
 111                {
 1112                    subFolderPrefix = c.ToString();
 1113                    break;
 114                }
 115            }
 116
 1117            var path = ConfigurationManager.ApplicationPaths.PeoplePath;
 118
 1119            return string.IsNullOrEmpty(subFolderPrefix) ?
 1120                System.IO.Path.Combine(path, validFilename) :
 1121                System.IO.Path.Combine(path, subFolderPrefix, validFilename);
 122        }
 123
 124        private string GetRebasedPath()
 125        {
 0126            return GetPath(System.IO.Path.GetFileName(Path), false);
 127        }
 128
 129        public override bool RequiresRefresh()
 130        {
 0131            var newPath = GetRebasedPath();
 0132            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 133            {
 0134                Logger.LogDebug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath);
 0135                return true;
 136            }
 137
 0138            return base.RequiresRefresh();
 139        }
 140
 141        /// <summary>
 142        /// This is called before any metadata refresh and returns true or false indicating if changes were made.
 143        /// </summary>
 144        /// <param name="replaceAllMetadata"><c>true</c> to replace all metadata, <c>false</c> to not.</param>
 145        /// <returns><c>true</c> if changes were made, <c>false</c> if not.</returns>
 146        public override bool BeforeMetadataRefresh(bool replaceAllMetadata)
 147        {
 0148            var hasChanges = base.BeforeMetadataRefresh(replaceAllMetadata);
 149
 0150            var newPath = GetRebasedPath();
 0151            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 152            {
 0153                Path = newPath;
 0154                hasChanges = true;
 155            }
 156
 0157            return hasChanges;
 158        }
 159    }
 160}