From 60067b4c29ccdfe19102a47eb9347715e1904b22 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 2 Nov 2015 23:34:47 -0500 Subject: fix camera upload folder --- .../Devices/DeviceManager.cs | 98 ++++++++++++++++++++-- 1 file changed, 90 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Devices/DeviceManager.cs') diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs index 0b2c082a8..e0713bfd5 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs @@ -18,6 +18,9 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using CommonIO; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Plugins; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Server.Implementations.Devices { @@ -27,7 +30,7 @@ namespace MediaBrowser.Server.Implementations.Devices private readonly IUserManager _userManager; private readonly IFileSystem _fileSystem; private readonly ILibraryMonitor _libraryMonitor; - private readonly IConfigurationManager _config; + private readonly IServerConfigurationManager _config; private readonly ILogger _logger; private readonly INetworkManager _network; @@ -38,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.Devices /// public event EventHandler> DeviceOptionsUpdated; - public DeviceManager(IDeviceRepository repo, IUserManager userManager, IFileSystem fileSystem, ILibraryMonitor libraryMonitor, IConfigurationManager config, ILogger logger, INetworkManager network) + public DeviceManager(IDeviceRepository repo, IUserManager userManager, IFileSystem fileSystem, ILibraryMonitor libraryMonitor, IServerConfigurationManager config, ILogger logger, INetworkManager network) { _repo = repo; _userManager = userManager; @@ -187,11 +190,6 @@ namespace MediaBrowser.Server.Implementations.Devices } } - private string GetUploadPath(string deviceId) - { - return GetUploadPath(GetDevice(deviceId)); - } - private string GetUploadPath(DeviceInfo device) { if (!string.IsNullOrWhiteSpace(device.CameraUploadPath)) @@ -205,16 +203,81 @@ namespace MediaBrowser.Server.Implementations.Devices return config.CameraUploadPath; } - var path = Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads"); + var path = DefaultCameraUploadsPath; if (config.EnableCameraUploadSubfolders) { path = Path.Combine(path, _fileSystem.GetValidFilename(device.Name)); } + EnsureMediaLibrarySetup(); + return path; } + private string DefaultCameraUploadsPath + { + get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads"); } + } + + internal void EnsureMediaLibrarySetup() + { + //EnsureMediaLibrarySetup(DefaultCameraUploadsPath, false); + } + + private void EnsureMediaLibrarySetup(string libraryPath, bool force) + { + var requiresSetup = false; + + var path = Path.Combine(_config.ApplicationPaths.DefaultUserViewsPath, "Camera Uploads"); + + var collectionMarkerFile = Path.Combine(path, CollectionType.Photos + ".collection"); + if (!_fileSystem.FileExists(collectionMarkerFile)) + { + requiresSetup = true; + } + + var shortcutFile = Path.Combine(path, "camerauploads.mblink"); + try + { + if (!string.Equals(_fileSystem.ReadAllText(shortcutFile), libraryPath)) + { + requiresSetup = true; + } + } + catch + { + requiresSetup = true; + } + + if (requiresSetup) + { + if (!force) + { + var extensions = new[] { ".jpg", ".png" }; + var hasPhotos = _fileSystem.GetFiles(libraryPath, true).Any(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)); + + // Nothing to do + if (!hasPhotos) + { + return; + } + } + } + + if (requiresSetup) + { + Directory.CreateDirectory(path); + + using (File.Create(collectionMarkerFile)) + { + + } + + _fileSystem.CreateShortcut(shortcutFile, libraryPath); + } + } + public async Task UpdateDeviceInfo(string id, DeviceOptions options) { var device = GetDevice(id); @@ -274,6 +337,25 @@ namespace MediaBrowser.Server.Implementations.Devices } } + public class DeviceManagerEntryPoint : IServerEntryPoint + { + private readonly IDeviceManager _deviceManager; + + public DeviceManagerEntryPoint(IDeviceManager deviceManager) + { + _deviceManager = deviceManager; + } + + public void Run() + { + ((DeviceManager)_deviceManager).EnsureMediaLibrarySetup(); + } + + public void Dispose() + { + } + } + public class DevicesConfigStore : IConfigurationFactory { public IEnumerable GetConfigurations() -- cgit v1.2.3 From e36b2e9ca2ec2c7e925e941cd50b42e5c22078e9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 25 Nov 2015 13:29:45 -0500 Subject: removed dead code --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 1 - MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 38 +--------- MediaBrowser.Api/Playback/StreamRequest.cs | 1 - .../Devices/DeviceManager.cs | 82 ---------------------- 4 files changed, 1 insertion(+), 121 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Devices/DeviceManager.cs') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index d98e2f3a1..1b5e6e865 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -130,7 +130,6 @@ namespace MediaBrowser.Api.Playback data += "-" + (state.Request.DeviceId ?? string.Empty); data += "-" + (state.Request.PlaySessionId ?? string.Empty); - data += "-" + (state.Request.ClientTime ?? string.Empty); var dataHash = data.GetMD5().ToString("N"); diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index be9c548cf..546b1ec5f 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.IO; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Dlna; @@ -475,41 +474,6 @@ namespace MediaBrowser.Api.Playback.Hls await Task.Delay(100, cancellationToken).ConfigureAwait(false); } - // if a different file is encoding, it's done - //var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath); - //if (currentTranscodingIndex > segmentIndex) - //{ - //return GetSegmentResult(segmentPath, segmentIndex); - //} - - //// Wait for the file to stop being written to, then stream it - //var length = new FileInfo(segmentPath).Length; - //var eofCount = 0; - - //while (eofCount < 10) - //{ - // var info = new FileInfo(segmentPath); - - // if (!info.Exists) - // { - // break; - // } - - // var newLength = info.Length; - - // if (newLength == length) - // { - // eofCount++; - // } - // else - // { - // eofCount = 0; - // } - - // length = newLength; - // await Task.Delay(100, cancellationToken).ConfigureAwait(false); - //} - cancellationToken.ThrowIfCancellationRequested(); return GetSegmentResult(state, segmentPath, segmentIndex, transcodingJob); } diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index 75242e604..69f8e6e04 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -70,7 +70,6 @@ namespace MediaBrowser.Api.Playback public string DeviceProfileId { get; set; } public string Params { get; set; } - public string ClientTime { get; set; } public string PlaySessionId { get; set; } public string LiveStreamId { get; set; } } diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs index e0713bfd5..6b1af8d2d 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Events; -using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Library; @@ -19,8 +18,6 @@ using System.Linq; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Plugins; -using MediaBrowser.Model.Entities; namespace MediaBrowser.Server.Implementations.Devices { @@ -210,8 +207,6 @@ namespace MediaBrowser.Server.Implementations.Devices path = Path.Combine(path, _fileSystem.GetValidFilename(device.Name)); } - EnsureMediaLibrarySetup(); - return path; } @@ -220,64 +215,6 @@ namespace MediaBrowser.Server.Implementations.Devices get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads"); } } - internal void EnsureMediaLibrarySetup() - { - //EnsureMediaLibrarySetup(DefaultCameraUploadsPath, false); - } - - private void EnsureMediaLibrarySetup(string libraryPath, bool force) - { - var requiresSetup = false; - - var path = Path.Combine(_config.ApplicationPaths.DefaultUserViewsPath, "Camera Uploads"); - - var collectionMarkerFile = Path.Combine(path, CollectionType.Photos + ".collection"); - if (!_fileSystem.FileExists(collectionMarkerFile)) - { - requiresSetup = true; - } - - var shortcutFile = Path.Combine(path, "camerauploads.mblink"); - try - { - if (!string.Equals(_fileSystem.ReadAllText(shortcutFile), libraryPath)) - { - requiresSetup = true; - } - } - catch - { - requiresSetup = true; - } - - if (requiresSetup) - { - if (!force) - { - var extensions = new[] { ".jpg", ".png" }; - var hasPhotos = _fileSystem.GetFiles(libraryPath, true).Any(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)); - - // Nothing to do - if (!hasPhotos) - { - return; - } - } - } - - if (requiresSetup) - { - Directory.CreateDirectory(path); - - using (File.Create(collectionMarkerFile)) - { - - } - - _fileSystem.CreateShortcut(shortcutFile, libraryPath); - } - } - public async Task UpdateDeviceInfo(string id, DeviceOptions options) { var device = GetDevice(id); @@ -337,25 +274,6 @@ namespace MediaBrowser.Server.Implementations.Devices } } - public class DeviceManagerEntryPoint : IServerEntryPoint - { - private readonly IDeviceManager _deviceManager; - - public DeviceManagerEntryPoint(IDeviceManager deviceManager) - { - _deviceManager = deviceManager; - } - - public void Run() - { - ((DeviceManager)_deviceManager).EnsureMediaLibrarySetup(); - } - - public void Dispose() - { - } - } - public class DevicesConfigStore : IConfigurationFactory { public IEnumerable GetConfigurations() -- cgit v1.2.3