The Free Software Media System - Server Backend & API
fix camera upload folder
Luke Pulverenti60067b4c29cc
diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.csindex 319bc13fd2..904e8cdf64 100644--- a/MediaBrowser.Api/Library/LibraryService.cs+++ b/MediaBrowser.Api/Library/LibraryService.cs@@ -416,7 +416,7 @@ namespace MediaBrowser.Api.Librarypublic 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.csindex e6f3225950..b7946cb928 100644--- a/MediaBrowser.Controller/Entities/UserRootFolder.cs+++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs@@ -57,7 +57,10 @@ namespace MediaBrowser.Controller.Entitiesprotected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user){- return base.GetEligibleChildrenForRecursiveChildren(user).Concat(LibraryManager.RootFolder.VirtualChildren);+ var list = base.GetEligibleChildrenForRecursiveChildren(user).ToList();+ list.AddRange(LibraryManager.RootFolder.VirtualChildren);++ return list;}/// <summary>diff --git a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs b/MediaBrowser.Providers/Folders/DefaultImageProvider.csindex 74db706524..830a8c0162 100644--- a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs+++ b/MediaBrowser.Providers/Folders/DefaultImageProvider.cs@@ -77,15 +77,15 @@ namespace MediaBrowser.Providers.Foldersif (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.csindex 62069736f9..d1e66abcec 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.Devicesreturn _hasChildren.Value;}- protected override System.Threading.Tasks.Task ValidateChildrenInternal(IProgress<double> progress, System.Threading.CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, Controller.Providers.MetadataRefreshOptions refreshOptions, Controller.Providers.IDirectoryService directoryService)+ protected override Task ValidateChildrenInternal(IProgress<double> 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.csindex 0b2c082a85..e0713bfd5d 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.Devicesprivate 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/// </summary>public event EventHandler<GenericEventArgs<DeviceInfo>> 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.Devicesreturn 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<ConfigurationStore> GetConfigurations()diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csprojindex 24bc420246..b4d019d133 100644--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj@@ -120,9 +120,9 @@<Compile Include="Connect\ConnectManager.cs" /><Compile Include="Connect\Responses.cs" /><Compile Include="Connect\Validator.cs" />+ <Compile Include="Devices\CameraUploadsFolder.cs" /><Compile Include="Devices\DeviceManager.cs" /><Compile Include="Devices\DeviceRepository.cs" />- <Compile Include="Devices\CameraUploadsFolder.cs" /><Compile Include="Dto\DtoService.cs" /><Compile Include="EntryPoints\ActivityLogEntryPoint.cs" /><Compile Include="EntryPoints\AutomaticRestartEntryPoint.cs" />diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex 6fc25f24c3..2f098aad0f 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -465,7 +465,7 @@ namespace MediaBrowser.Server.Startup.CommonConnectManager = 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);