diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs index eac08686f..f10244a2c 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Devices; using MediaBrowser.Model.Devices; +using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Session; using System; @@ -19,6 +20,7 @@ namespace MediaBrowser.Server.Implementations.Devices private readonly IApplicationPaths _appPaths; private readonly IJsonSerializer _json; + private ILogger _logger; private ConcurrentBag<DeviceInfo> _devices; @@ -69,7 +71,8 @@ namespace MediaBrowser.Server.Implementations.Devices public DeviceInfo GetDevice(string id) { - return GetDevices().FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase)); + return GetDevices() + .FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase)); } public IEnumerable<DeviceInfo> GetDevices() @@ -96,7 +99,19 @@ namespace MediaBrowser.Server.Implementations.Devices return new DirectoryInfo(path) .EnumerateFiles("*", SearchOption.AllDirectories) .Where(i => string.Equals(i.Name, "device.json", StringComparison.OrdinalIgnoreCase)) - .Select(i => _json.DeserializeFromFile<DeviceInfo>(i.FullName)) + .Select(i => + { + try + { + return _json.DeserializeFromFile<DeviceInfo>(i.FullName); + } + catch (Exception ex) + { + _logger.ErrorException("Error reading {0}", ex, i.FullName); + return null; + } + }) + .Where(i => i != null) .ToList(); } catch (IOException) |
