diff options
| author | PloughPuff <ploughpuff@protonmail.com> | 2019-02-20 13:29:34 +0000 |
|---|---|---|
| committer | PloughPuff <ploughpuff@protonmail.com> | 2019-02-20 13:30:06 +0000 |
| commit | 73c1cdb32ad8c0adf5e48477294dbee0f9240e8d (patch) | |
| tree | b962e76303eeb05d918011ca1d6735090c8226a5 /Emby.Server.Implementations | |
| parent | 99bed9a9c3791bcff648029088d766f1dfde3a96 (diff) | |
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.
Diffstat (limited to 'Emby.Server.Implementations')
| -rw-r--r-- | Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index b825ea3b0..a2ac60b31 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/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>(); } |
