fix camera upload folder

This commit is contained in:
Luke Pulverenti 2015-11-02 23:34:47 -05:00
parent f6c8e5b4d6
commit 60067b4c29
7 changed files with 112 additions and 24 deletions

View File

@ -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)
{

View File

@ -57,7 +57,10 @@ namespace MediaBrowser.Controller.Entities
protected 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>

View File

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

View File

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

View File

@ -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
/// </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.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<ConfigurationStore> GetConfigurations()

View File

@ -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" />

View File

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