< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Library.PathManager
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Library/PathManager.cs
Line coverage
20%
Covered lines: 3
Uncovered lines: 12
Coverable lines: 15
Total lines: 73
Line coverage: 20%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_SubtitleCachePath()100%210%
get_AttachmentCachePath()100%210%
GetAttachmentPath(...)100%210%
GetAttachmentFolderPath(...)100%210%
GetSubtitleFolderPath(...)100%210%
GetSubtitlePath(...)100%210%
GetTrickplayDirectory(...)0%620%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Library/PathManager.cs

#LineLine coverage
 1using System;
 2using System.Globalization;
 3using System.IO;
 4using MediaBrowser.Common.Configuration;
 5using MediaBrowser.Controller.Configuration;
 6using MediaBrowser.Controller.Entities;
 7using MediaBrowser.Controller.IO;
 8
 9namespace Emby.Server.Implementations.Library;
 10
 11/// <summary>
 12/// IPathManager implementation.
 13/// </summary>
 14public class PathManager : IPathManager
 15{
 16    private readonly IServerConfigurationManager _config;
 17    private readonly IApplicationPaths _appPaths;
 18
 19    /// <summary>
 20    /// Initializes a new instance of the <see cref="PathManager"/> class.
 21    /// </summary>
 22    /// <param name="config">The server configuration manager.</param>
 23    /// <param name="appPaths">The application paths.</param>
 24    public PathManager(
 25        IServerConfigurationManager config,
 26        IApplicationPaths appPaths)
 27    {
 2128        _config = config;
 2129        _appPaths = appPaths;
 2130    }
 31
 032    private string SubtitleCachePath => Path.Combine(_appPaths.DataPath, "subtitles");
 33
 034    private string AttachmentCachePath => Path.Combine(_appPaths.DataPath, "attachments");
 35
 36    /// <inheritdoc />
 37    public string GetAttachmentPath(string mediaSourceId, string fileName)
 38    {
 039        return Path.Join(GetAttachmentFolderPath(mediaSourceId), fileName);
 40    }
 41
 42    /// <inheritdoc />
 43    public string GetAttachmentFolderPath(string mediaSourceId)
 44    {
 045        var id = Guid.Parse(mediaSourceId).ToString("D", CultureInfo.InvariantCulture).AsSpan();
 46
 047        return Path.Join(AttachmentCachePath, id[..2], id);
 48    }
 49
 50    /// <inheritdoc />
 51    public string GetSubtitleFolderPath(string mediaSourceId)
 52    {
 053        var id = Guid.Parse(mediaSourceId).ToString("D", CultureInfo.InvariantCulture).AsSpan();
 54
 055        return Path.Join(SubtitleCachePath, id[..2], id);
 56    }
 57
 58    /// <inheritdoc />
 59    public string GetSubtitlePath(string mediaSourceId, int streamIndex, string extension)
 60    {
 061        return Path.Join(GetSubtitleFolderPath(mediaSourceId), streamIndex.ToString(CultureInfo.InvariantCulture) + exte
 62    }
 63
 64    /// <inheritdoc />
 65    public string GetTrickplayDirectory(BaseItem item, bool saveWithMedia = false)
 66    {
 067        var id = item.Id.ToString("D", CultureInfo.InvariantCulture).AsSpan();
 68
 069        return saveWithMedia
 070            ? Path.Combine(item.ContainingFolderPath, Path.ChangeExtension(item.Path, ".trickplay"))
 071            : Path.Join(_config.ApplicationPaths.TrickplayPath, id[..2], id);
 72    }
 73}