diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-11-04 07:41:12 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-11-04 07:41:12 -0500 |
| commit | 60d3f475033cef64a8f3153beb910e48529c8e16 (patch) | |
| tree | 7774f0c55cebc17f459965e03094d05e88f465f2 /MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs | |
| parent | 7ca1cd8795c465953ddb4560ce62fe6efba9f9d3 (diff) | |
add server management to web client
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) |
