瀏覽代碼

Avoid exceptions due to folder and file not found

1) Use function to return path to temp transcode path which has benefit of creating temp folder if not exists, thereby avoiding the exception when GetFilePaths is used.
2) Check json files exists before attempting to read from it.  Avoids having to mask FileNotFound exceptions when debugging.
PloughPuff 6 年之前
父節點
當前提交
73c1cdb32a
共有 2 個文件被更改,包括 7 次插入4 次删除
  1. 6 3
      Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
  2. 1 1
      MediaBrowser.Api/ApiEntryPoint.cs

+ 6 - 3
Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs

@@ -43,12 +43,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
         {
             var jsonFile = path + ".json";
 
-            try
+            if (!File.Exists(jsonFile))
             {
-                return _jsonSerializer.DeserializeFromFile<List<T>>(jsonFile) ?? new List<T>();
+                return new List<T>();
             }
-            catch (FileNotFoundException)
+
+            try
             {
+                return _jsonSerializer.DeserializeFromFile<List<T>>(jsonFile) ?? new List<T>();
             }
             catch (IOException)
             {
@@ -57,6 +59,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             {
                 Logger.LogError(ex, "Error deserializing {jsonFile}", jsonFile);
             }
+
             return new List<T>();
         }
 

+ 1 - 1
MediaBrowser.Api/ApiEntryPoint.cs

@@ -170,7 +170,7 @@ namespace MediaBrowser.Api
         /// </summary>
         private void DeleteEncodedMediaCache()
         {
-            var path = _config.ApplicationPaths.TranscodingTempPath;
+            var path = _config.ApplicationPaths.GetTranscodingTempPath();
 
             foreach (var file in _fileSystem.GetFilePaths(path, true))
             {