diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Devices')
3 files changed, 11 insertions, 6 deletions
diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs index 566f4c5f4..15567703d 100644 --- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs +++ b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -3,6 +3,7 @@ using MediaBrowser.Controller.Entities; using System; using System.IO; using System.Linq; +using MediaBrowser.Common.IO; namespace MediaBrowser.Server.Implementations.Devices { @@ -51,17 +52,19 @@ namespace MediaBrowser.Server.Implementations.Devices public class CameraUploadsDynamicFolder : IVirtualFolderCreator { private readonly IApplicationPaths _appPaths; + private readonly IFileSystem _fileSystem; - public CameraUploadsDynamicFolder(IApplicationPaths appPaths) + public CameraUploadsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem) { _appPaths = appPaths; + _fileSystem = fileSystem; } public BasePluginFolder GetFolder() { var path = Path.Combine(_appPaths.DataPath, "camerauploads"); - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); return new CameraUploadsFolder { diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs index 04337dda6..a6a8b3a7a 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs @@ -8,6 +8,7 @@ using MediaBrowser.Model.Devices; using MediaBrowser.Model.Events; using MediaBrowser.Model.Extensions; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Net; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Session; using MediaBrowser.Model.Users; @@ -151,12 +152,13 @@ namespace MediaBrowser.Server.Implementations.Devices path = Path.Combine(path, _fileSystem.GetValidFilename(file.Album)); } - Directory.CreateDirectory(path); - path = Path.Combine(path, file.Name); + path = Path.ChangeExtension(path, MimeTypes.ToExtension(file.MimeType) ?? "jpg"); _libraryMonitor.ReportFileSystemChangeBeginning(path); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + try { using (var fs = _fileSystem.GetFileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read)) diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs index 6d324b1ab..b8262d05f 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.Devices public Task SaveDevice(DeviceInfo device) { var path = Path.Combine(GetDevicePath(device.Id), "device.json"); - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_syncLock) { @@ -178,7 +178,7 @@ namespace MediaBrowser.Server.Implementations.Devices public void AddCameraUpload(string deviceId, LocalFileInfo file) { var path = Path.Combine(GetDevicePath(deviceId), "camerauploads.json"); - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_syncLock) { |
