aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2020-04-26 16:02:09 -0400
committerJoshua M. Boniface <joshua@boniface.me>2020-04-26 16:03:58 -0400
commita3d048a0d9806759683fa417edd57c2b0170529c (patch)
treecbe6ec323d939075c0a44cc8893ac8e2b411b4b1 /MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
parent21a6c2e1e266ea9d164b31aa492e53ec3d0e068e (diff)
Merge pull request #2990 from mark-monteiro/create-missing-foldersv10.5.5
Create Missing Data Folders (cherry picked from commit 00d8983d7cec0594efac8d85a927dba3c3391bdf) Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
Diffstat (limited to 'MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs')
-rw-r--r--MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs14
1 files changed, 11 insertions, 3 deletions
diff --git a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
index ccf965898..89740ae08 100644
--- a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
+++ b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
@@ -1,3 +1,4 @@
+using System;
using System.IO;
using MediaBrowser.Model.Configuration;
@@ -17,18 +18,25 @@ namespace MediaBrowser.Common.Configuration
=> configurationManager.GetConfiguration<EncodingOptions>("encoding");
/// <summary>
- /// Retrieves the transcoding temp path from the encoding configuration.
+ /// Retrieves the transcoding temp path from the encoding configuration, falling back to a default if no path
+ /// is specified in configuration. If the directory does not exist, it will be created.
/// </summary>
- /// <param name="configurationManager">The Configuration manager.</param>
+ /// <param name="configurationManager">The configuration manager.</param>
/// <returns>The transcoding temp path.</returns>
+ /// <exception cref="UnauthorizedAccessException">If the directory does not exist, and the caller does not have the required permission to create it.</exception>
+ /// <exception cref="NotSupportedException">If there is a custom path transcoding path specified, but it is invalid.</exception>
+ /// <exception cref="IOException">If the directory does not exist, and it also could not be created.</exception>
public static string GetTranscodePath(this IConfigurationManager configurationManager)
{
+ // Get the configured path and fall back to a default
var transcodingTempPath = configurationManager.GetEncodingOptions().TranscodingTempPath;
if (string.IsNullOrEmpty(transcodingTempPath))
{
- return Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes");
+ transcodingTempPath = Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes");
}
+ // Make sure the directory exists
+ Directory.CreateDirectory(transcodingTempPath);
return transcodingTempPath;
}
}