From 0ac0d6b87858f0d0d8cc3b891b9f295bb8a143d7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 30 Oct 2015 11:23:06 -0400 Subject: update special folders --- .../Devices/CameraUploadsFolder.cs | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Devices') diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs index 6d7265972..62069736f 100644 --- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs +++ b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -21,32 +21,35 @@ namespace MediaBrowser.Server.Implementations.Devices { return false; } - - return GetChildren(user, true).Any() && - base.IsVisible(user); + + return base.IsVisible(user) && HasChildren(); } - public override bool IsHidden + public override string CollectionType { - get - { - return base.IsHidden || !Children.Any(); - } + get { return Model.Entities.CollectionType.Photos; } } - public override bool IsHiddenFromUser(User user) + public override string GetClientTypeName() { - return false; + return typeof(CollectionFolder).Name; } - public override string CollectionType + private bool? _hasChildren; + private bool HasChildren() { - get { return Model.Entities.CollectionType.Photos; } + if (!_hasChildren.HasValue) + { + _hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { ParentId = Id }).Count > 0; + } + + return _hasChildren.Value; } - public override string GetClientTypeName() + protected override System.Threading.Tasks.Task ValidateChildrenInternal(IProgress progress, System.Threading.CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, Controller.Providers.MetadataRefreshOptions refreshOptions, Controller.Providers.IDirectoryService directoryService) { - return typeof(CollectionFolder).Name; + _hasChildren = null; + return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); } } @@ -65,7 +68,7 @@ namespace MediaBrowser.Server.Implementations.Devices { var path = Path.Combine(_appPaths.DataPath, "camerauploads"); - _fileSystem.CreateDirectory(path); + _fileSystem.CreateDirectory(path); return new CameraUploadsFolder { -- cgit v1.2.3 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 --- MediaBrowser.Api/Library/LibraryService.cs | 2 +- MediaBrowser.Controller/Entities/UserRootFolder.cs | 5 +- .../Folders/DefaultImageProvider.cs | 22 ++--- .../Devices/CameraUploadsFolder.cs | 5 +- .../Devices/DeviceManager.cs | 98 ++++++++++++++++++++-- .../MediaBrowser.Server.Implementations.csproj | 2 +- .../ApplicationHost.cs | 2 +- 7 files changed, 112 insertions(+), 24 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Devices') diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 319bc13fd..904e8cdf6 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -416,7 +416,7 @@ namespace MediaBrowser.Api.Library public object Get(GetMediaFolders request) { - var items = _libraryManager.GetUserRootFolder().Children.OrderBy(i => i.SortName).ToList(); + var items = _libraryManager.GetUserRootFolder().Children.Concat(_libraryManager.RootFolder.VirtualChildren).OrderBy(i => i.SortName).ToList(); if (request.IsHidden.HasValue) { diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index e6f322595..b7946cb92 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -57,7 +57,10 @@ namespace MediaBrowser.Controller.Entities protected override IEnumerable GetEligibleChildrenForRecursiveChildren(User user) { - return base.GetEligibleChildrenForRecursiveChildren(user).Concat(LibraryManager.RootFolder.VirtualChildren); + var list = base.GetEligibleChildrenForRecursiveChildren(user).ToList(); + list.AddRange(LibraryManager.RootFolder.VirtualChildren); + + return list; } /// diff --git a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs b/MediaBrowser.Providers/Folders/DefaultImageProvider.cs index 74db70652..830a8c016 100644 --- a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs +++ b/MediaBrowser.Providers/Folders/DefaultImageProvider.cs @@ -77,15 +77,15 @@ namespace MediaBrowser.Providers.Folders if (string.Equals(viewType, CollectionType.Books, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "books.png"; + return urlPrefix + "books.jpg"; } if (string.Equals(viewType, CollectionType.Games, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "games.png"; + return urlPrefix + "games.jpg"; } if (string.Equals(viewType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "music.png"; + return urlPrefix + "music.jpg"; } if (string.Equals(viewType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) { @@ -93,11 +93,11 @@ namespace MediaBrowser.Providers.Folders } if (string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "tv.png"; + return urlPrefix + "tv.jpg"; } if (string.Equals(viewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "generic.png"; + return urlPrefix + "channels.jpg"; } if (string.Equals(viewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase)) { @@ -105,27 +105,27 @@ namespace MediaBrowser.Providers.Folders } if (string.Equals(viewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "movies.png"; + return urlPrefix + "movies.jpg"; } if (string.Equals(viewType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "playlists.png"; + return urlPrefix + "playlists.jpg"; } if (string.Equals(viewType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "homevideos.png"; + return urlPrefix + "homevideos.jpg"; } if (string.Equals(viewType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "musicvideos.png"; + return urlPrefix + "musicvideos.jpg"; } if (string.Equals(viewType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) { - //return urlPrefix + "generic.png"; + return urlPrefix + "collections.jpg"; } if (string.IsNullOrWhiteSpace(viewType)) { - //return urlPrefix + "generic.png"; + return urlPrefix + "generic.jpg"; } return null; diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs index 62069736f..d1e66abce 100644 --- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs +++ b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -3,8 +3,11 @@ using MediaBrowser.Controller.Entities; using System; using System.IO; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using CommonIO; using MediaBrowser.Common.IO; +using MediaBrowser.Controller.Providers; namespace MediaBrowser.Server.Implementations.Devices { @@ -46,7 +49,7 @@ namespace MediaBrowser.Server.Implementations.Devices return _hasChildren.Value; } - protected override System.Threading.Tasks.Task ValidateChildrenInternal(IProgress progress, System.Threading.CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, Controller.Providers.MetadataRefreshOptions refreshOptions, Controller.Providers.IDirectoryService directoryService) + protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { _hasChildren = null; return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); 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() diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 24bc42024..b4d019d13 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -120,9 +120,9 @@ + - diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 6fc25f24c..2f098aad0 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -465,7 +465,7 @@ namespace MediaBrowser.Server.Startup.Common ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager, SecurityManager, FileSystemManager); RegisterSingleInstance(ConnectManager); - DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager); + DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager); RegisterSingleInstance(DeviceManager); var newsService = new Implementations.News.NewsService(ApplicationPaths, JsonSerializer); -- cgit v1.2.3 From e32dcb38e4dea354bcba8875717d396fa6ce1129 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 14 Nov 2015 11:58:01 -0500 Subject: update timeline view --- .../Entities/ICollectionFolder.cs | 5 +++ MediaBrowser.Controller/Entities/UserView.cs | 12 +++++- .../Collections/CollectionImageProvider.cs | 19 +-------- .../Devices/CameraUploadsFolder.cs | 10 ++++- .../Library/UserViewManager.cs | 47 +++++++++++----------- .../MediaBrowser.Server.Implementations.csproj | 1 + .../Photos/BaseDynamicImageProvider.cs | 20 +++++++++ .../Photos/PhotoAlbumImageProvider.cs | 19 +-------- 8 files changed, 73 insertions(+), 60 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Devices') diff --git a/MediaBrowser.Controller/Entities/ICollectionFolder.cs b/MediaBrowser.Controller/Entities/ICollectionFolder.cs index b55ca0a17..f4544f173 100644 --- a/MediaBrowser.Controller/Entities/ICollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/ICollectionFolder.cs @@ -16,6 +16,11 @@ namespace MediaBrowser.Controller.Entities IEnumerable PhysicalLocations { get; } } + public interface ISupportsUserSpecificView + { + bool EnableUserSpecificView { get; } + } + public static class CollectionFolderExtensions { public static string GetViewType(this ICollectionFolder folder, User user) diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index f14ba568b..2379326a1 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -144,12 +144,22 @@ namespace MediaBrowser.Controller.Entities return false; } + var supportsUserSpecific = folder as ISupportsUserSpecificView; + if (supportsUserSpecific != null && supportsUserSpecific.EnableUserSpecificView) + { + return true; + } + return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty); } public static bool IsEligibleForEnhancedView(string viewType) { - var types = new[] { CollectionType.Movies, CollectionType.TvShows }; + var types = new[] + { + CollectionType.Movies, + CollectionType.TvShows + }; return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase); } diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs b/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs index bcb377537..7ed0d43b1 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs @@ -78,24 +78,9 @@ namespace MediaBrowser.Server.Implementations.Collections return Task.FromResult(GetFinalItems(items, 2)); } - protected override async Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) + protected override Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) { - var image = itemsWithImages - .Where(i => i.HasImage(ImageType.Primary) && i.GetImageInfo(ImageType.Primary, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(ImageType.Primary))) - .Select(i => i.GetImagePath(ImageType.Primary)) - .FirstOrDefault(); - - if (string.IsNullOrWhiteSpace(image)) - { - return null; - } - - var ext = Path.GetExtension(image); - - var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext); - File.Copy(image, outputPath); - - return outputPath; + return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary); } } } diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs index d1e66abce..947933561 100644 --- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs +++ b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -3,15 +3,15 @@ using MediaBrowser.Controller.Entities; using System; using System.IO; using System.Linq; +using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; using CommonIO; -using MediaBrowser.Common.IO; using MediaBrowser.Controller.Providers; namespace MediaBrowser.Server.Implementations.Devices { - public class CameraUploadsFolder : BasePluginFolder + public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView { public CameraUploadsFolder() { @@ -54,6 +54,12 @@ namespace MediaBrowser.Server.Implementations.Devices _hasChildren = null; return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); } + + [IgnoreDataMember] + public bool EnableUserSpecificView + { + get { return true; } + } } public class CameraUploadsDynamicFolder : IVirtualFolderCreator diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index b869d181e..98a375923 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -73,20 +73,26 @@ namespace MediaBrowser.Server.Implementations.Library var enableUserViews = _config.Configuration.EnableUserViews || user.EnableUserViews; - if (enableUserViews) + foreach (var folder in standaloneFolders) { - foreach (var folder in standaloneFolders) - { - var collectionFolder = folder as ICollectionFolder; - var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType; + var collectionFolder = folder as ICollectionFolder; + var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType; - if (UserView.IsUserSpecific(folder)) + if (UserView.IsUserSpecific(folder)) + { + list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false)); + continue; + } + + if (enableUserViews) + { + if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType)) { - list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(folder, folderViewType, false, string.Empty, cancellationToken).ConfigureAwait(false)); } - else if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType)) + else if (_config.Configuration.EnableSharedCollectionViewImage) { - list.Add(await GetUserView(folder, folderViewType, false, string.Empty, cancellationToken).ConfigureAwait(false)); + list.Add(folder); } else if (!string.IsNullOrWhiteSpace(folderViewType)) { @@ -97,20 +103,10 @@ namespace MediaBrowser.Server.Implementations.Library list.Add(folder); } } - } - else - { - // TODO: Deprecate this whole block - foreach (var folder in standaloneFolders) + else { - var collectionFolder = folder as ICollectionFolder; - var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType; - - if (UserView.IsUserSpecific(folder)) - { - list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false)); - } - else if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType)) + // TODO: Deprecate this whole block + if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType)) { list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false)); } @@ -203,10 +199,15 @@ namespace MediaBrowser.Server.Implementations.Library return GetUserSubView(name, parentId, type, sortName, cancellationToken); } - private async Task GetUserView(List parents, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken) + private async Task GetUserView(List parents, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken) { if (parents.Count == 1 && parents.All(i => string.Equals((enableUserViews ? i.GetViewType(user) : i.CollectionType), viewType, StringComparison.OrdinalIgnoreCase))) { + if (enableUserViews || _config.Configuration.EnableSharedCollectionViewImage) + { + return (Folder)parents[0]; + } + var parentId = parents[0].Id; var enableRichView = !user.Configuration.PlainFolderViews.Contains(parentId.ToString("N"), StringComparer.OrdinalIgnoreCase); diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index fba30e1e9..b963a2189 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -70,6 +70,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs index fd34e3248..c30d35ed2 100644 --- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs @@ -285,5 +285,25 @@ namespace MediaBrowser.Server.Implementations.Photos return 0; } } + + protected async Task CreateSingleImage(List itemsWithImages, string outputPathWithoutExtension, ImageType imageType) + { + var image = itemsWithImages + .Where(i => i.HasImage(imageType) && i.GetImageInfo(imageType, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(imageType))) + .Select(i => i.GetImagePath(imageType)) + .FirstOrDefault(); + + if (string.IsNullOrWhiteSpace(image)) + { + return null; + } + + var ext = Path.GetExtension(image); + + var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext); + File.Copy(image, outputPath); + + return outputPath; + } } } diff --git a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs index 3abb7e70e..56a174756 100644 --- a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs @@ -26,24 +26,9 @@ namespace MediaBrowser.Server.Implementations.Photos return Task.FromResult(items); } - protected override async Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) + protected override Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) { - var image = itemsWithImages - .Where(i => i.HasImage(ImageType.Primary) && i.GetImageInfo(ImageType.Primary, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(ImageType.Primary))) - .Select(i => i.GetImagePath(ImageType.Primary)) - .FirstOrDefault(); - - if (string.IsNullOrWhiteSpace(image)) - { - return null; - } - - var ext = Path.GetExtension(image); - - var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext); - File.Copy(image, outputPath); - - return outputPath; + return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary); } } } -- 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') 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 From 82495f9ac31da23c7c1ea3b425e5effb45b51bb9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 26 Jan 2016 13:18:21 -0500 Subject: rework device concurrency --- .../Devices/DeviceRepository.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Devices') diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs index 43b1e693c..9e4a45253 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Server.Implementations.Devices private readonly ILogger _logger; private readonly IFileSystem _fileSystem; - private ConcurrentBag _devices; + private List _devices; public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger, IFileSystem fileSystem) { @@ -93,17 +93,14 @@ namespace MediaBrowser.Server.Implementations.Devices public IEnumerable GetDevices() { - if (_devices == null) + lock (_syncLock) { - lock (_syncLock) + if (_devices == null) { - if (_devices == null) - { - _devices = new ConcurrentBag(LoadDevices()); - } + _devices = LoadDevices().ToList(); } + return _devices.ToList(); } - return _devices.ToList(); } private IEnumerable LoadDevices() -- cgit v1.2.3