From a3d048a0d9806759683fa417edd57c2b0170529c Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sun, 26 Apr 2020 16:02:09 -0400 Subject: Merge pull request #2990 from mark-monteiro/create-missing-folders Create Missing Data Folders (cherry picked from commit 00d8983d7cec0594efac8d85a927dba3c3391bdf) Signed-off-by: Joshua M. Boniface --- .../Configuration/EncodingConfigurationExtensions.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs') 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("encoding"); /// - /// 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. /// - /// The Configuration manager. + /// The configuration manager. /// The transcoding temp path. + /// If the directory does not exist, and the caller does not have the required permission to create it. + /// If there is a custom path transcoding path specified, but it is invalid. + /// If the directory does not exist, and it also could not be created. 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; } } -- cgit v1.2.3