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);