浏览代码

Don't set ffmpeg path from null to its Display value + add 404

cvium 3 年之前
父节点
当前提交
95f344722c
共有 1 个文件被更改,包括 16 次插入1 次删除
  1. 16 1
      MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

+ 16 - 1
MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

@@ -151,6 +151,16 @@ namespace MediaBrowser.MediaEncoding.Encoder
         /// <param name="pathType">The path type.</param>
         /// <param name="pathType">The path type.</param>
         public void UpdateEncoderPath(string path, string pathType)
         public void UpdateEncoderPath(string path, string pathType)
         {
         {
+            var config = _configurationManager.GetEncodingOptions();
+
+            // Filesystem may not be case insensitive, but EncoderAppPathDisplay should always point to a valid file?
+            if (string.IsNullOrEmpty(config.EncoderAppPath)
+                && string.Equals(config.EncoderAppPathDisplay, path, StringComparison.OrdinalIgnoreCase))
+            {
+                _logger.LogDebug("Existing ffmpeg path is empty and the new path is the same as {EncoderAppPathDisplay}. Skipping", nameof(config.EncoderAppPathDisplay));
+                return;
+            }
+
             string newPath;
             string newPath;
 
 
             _logger.LogInformation("Attempting to update encoder path to {Path}. pathType: {PathType}", path ?? string.Empty, pathType ?? string.Empty);
             _logger.LogInformation("Attempting to update encoder path to {Path}. pathType: {PathType}", path ?? string.Empty, pathType ?? string.Empty);
@@ -183,9 +193,14 @@ namespace MediaBrowser.MediaEncoding.Encoder
                 }
                 }
             }
             }
 
 
+            // Don't save an invalid path
+            if (!File.Exists(path))
+            {
+                throw new FileNotFoundException();
+            }
+
             // Write the new ffmpeg path to the xml as <EncoderAppPath>
             // Write the new ffmpeg path to the xml as <EncoderAppPath>
             // This ensures its not lost on next startup
             // This ensures its not lost on next startup
-            var config = _configurationManager.GetEncodingOptions();
             config.EncoderAppPath = newPath;
             config.EncoderAppPath = newPath;
             _configurationManager.SaveConfiguration("encoding", config);
             _configurationManager.SaveConfiguration("encoding", config);