< Summary - Jellyfin

Information
Class: MediaBrowser.Common.Configuration.EncodingConfigurationExtensions
Assembly: MediaBrowser.Common
File(s): /srv/git/jellyfin/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 43
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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
GetEncodingOptions(...)100%11100%
GetTranscodePath(...)100%22100%

File(s)

/srv/git/jellyfin/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3using MediaBrowser.Model.Configuration;
 4
 5namespace MediaBrowser.Common.Configuration
 6{
 7    /// <summary>
 8    /// Class containing extension methods for working with the encoding configuration.
 9    /// </summary>
 10    public static class EncodingConfigurationExtensions
 11    {
 12        /// <summary>
 13        /// Gets the encoding options.
 14        /// </summary>
 15        /// <param name="configurationManager">The configuration manager.</param>
 16        /// <returns>The encoding options.</returns>
 17        public static EncodingOptions GetEncodingOptions(this IConfigurationManager configurationManager)
 318            => configurationManager.GetConfiguration<EncodingOptions>("encoding");
 19
 20        /// <summary>
 21        /// Retrieves the transcoding temp path from the encoding configuration, falling back to a default if no path
 22        /// is specified in configuration. If the directory does not exist, it will be created.
 23        /// </summary>
 24        /// <param name="configurationManager">The configuration manager.</param>
 25        /// <returns>The transcoding temp path.</returns>
 26        /// <exception cref="UnauthorizedAccessException">If the directory does not exist, and the caller does not have 
 27        /// <exception cref="NotSupportedException">If there is a custom path transcoding path specified, but it is inva
 28        /// <exception cref="IOException">If the directory does not exist, and it also could not be created.</exception>
 29        public static string GetTranscodePath(this IConfigurationManager configurationManager)
 30        {
 31            // Get the configured path and fall back to a default
 332            var transcodingTempPath = configurationManager.GetEncodingOptions().TranscodingTempPath;
 333            if (string.IsNullOrEmpty(transcodingTempPath))
 34            {
 335                transcodingTempPath = Path.Combine(configurationManager.CommonApplicationPaths.CachePath, "transcodes");
 36            }
 37
 38            // Make sure the directory exists
 339            Directory.CreateDirectory(transcodingTempPath);
 340            return transcodingTempPath;
 41        }
 42    }
 43}