diff options
| author | Luke <luke.pulverenti@gmail.com> | 2015-02-09 16:58:30 -0500 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2015-02-09 16:58:30 -0500 |
| commit | 4cc3b2f0ccd7c092a4acf72db4903415e175037a (patch) | |
| tree | f9f90f8665b726253b8b357674f2f141aa43abc9 /MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs | |
| parent | e7037a9b80843c127712f11430239f8fa3cb4aed (diff) | |
| parent | 3d7089a7dbabb652730c892206ca050f52f832b1 (diff) | |
Merge pull request #1005 from MediaBrowser/dev
3.0.5518.0
Diffstat (limited to 'MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs index d587e5af7..6d324b1ab 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs @@ -1,5 +1,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Devices; using MediaBrowser.Model.Devices; using MediaBrowser.Model.Logging; @@ -21,14 +22,16 @@ namespace MediaBrowser.Server.Implementations.Devices private readonly IApplicationPaths _appPaths; private readonly IJsonSerializer _json; private readonly ILogger _logger; + private readonly IFileSystem _fileSystem; private ConcurrentBag<DeviceInfo> _devices; - public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger) + public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger, IFileSystem fileSystem) { _appPaths = appPaths; _json = json; _logger = logger; + _fileSystem = fileSystem; } private string GetDevicesPath() @@ -57,6 +60,12 @@ namespace MediaBrowser.Server.Implementations.Devices public Task SaveCapabilities(string reportedId, ClientCapabilities capabilities) { var device = GetDevice(reportedId); + + if (device == null) + { + throw new ArgumentException("No device has been registed with id " + reportedId); + } + device.Capabilities = capabilities; SaveDevice(device); @@ -72,6 +81,11 @@ namespace MediaBrowser.Server.Implementations.Devices public DeviceInfo GetDevice(string id) { + if (string.IsNullOrWhiteSpace(id)) + { + throw new ArgumentNullException("id"); + } + return GetDevices() .FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase)); } @@ -129,12 +143,12 @@ namespace MediaBrowser.Server.Implementations.Devices { try { - Directory.Delete(path, true); + _fileSystem.DeleteDirectory(path, true); } catch (DirectoryNotFoundException) { } - + _devices = null; } |
