2014-10-11 22:38:13 +02:00
|
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2015-03-02 06:16:29 +01:00
|
|
|
|
using System;
|
2014-10-11 22:38:13 +02:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2015-10-04 06:23:11 +02:00
|
|
|
|
using CommonIO;
|
2015-09-14 01:07:54 +02:00
|
|
|
|
using MediaBrowser.Common.IO;
|
2014-10-11 22:38:13 +02:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.Devices
|
|
|
|
|
{
|
|
|
|
|
public class CameraUploadsFolder : BasePluginFolder
|
|
|
|
|
{
|
|
|
|
|
public CameraUploadsFolder()
|
|
|
|
|
{
|
|
|
|
|
Name = "Camera Uploads";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsVisible(User user)
|
|
|
|
|
{
|
2015-03-02 06:16:29 +01:00
|
|
|
|
if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-10-30 16:23:06 +01:00
|
|
|
|
|
|
|
|
|
return base.IsVisible(user) && HasChildren();
|
2014-10-11 22:38:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-30 16:23:06 +01:00
|
|
|
|
public override string CollectionType
|
2014-10-11 22:38:13 +02:00
|
|
|
|
{
|
2015-10-30 16:23:06 +01:00
|
|
|
|
get { return Model.Entities.CollectionType.Photos; }
|
2014-10-11 22:38:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-30 16:23:06 +01:00
|
|
|
|
public override string GetClientTypeName()
|
2014-10-11 22:38:13 +02:00
|
|
|
|
{
|
2015-10-30 16:23:06 +01:00
|
|
|
|
return typeof(CollectionFolder).Name;
|
2014-10-11 22:38:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-30 16:23:06 +01:00
|
|
|
|
private bool? _hasChildren;
|
|
|
|
|
private bool HasChildren()
|
2014-10-11 22:38:13 +02:00
|
|
|
|
{
|
2015-10-30 16:23:06 +01:00
|
|
|
|
if (!_hasChildren.HasValue)
|
|
|
|
|
{
|
|
|
|
|
_hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { ParentId = Id }).Count > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _hasChildren.Value;
|
2014-10-11 22:38:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-30 16:23:06 +01:00
|
|
|
|
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)
|
2014-10-11 22:38:13 +02:00
|
|
|
|
{
|
2015-10-30 16:23:06 +01:00
|
|
|
|
_hasChildren = null;
|
|
|
|
|
return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService);
|
2014-10-11 22:38:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CameraUploadsDynamicFolder : IVirtualFolderCreator
|
|
|
|
|
{
|
|
|
|
|
private readonly IApplicationPaths _appPaths;
|
2015-09-14 01:07:54 +02:00
|
|
|
|
private readonly IFileSystem _fileSystem;
|
2014-10-11 22:38:13 +02:00
|
|
|
|
|
2015-09-14 01:07:54 +02:00
|
|
|
|
public CameraUploadsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem)
|
2014-10-11 22:38:13 +02:00
|
|
|
|
{
|
|
|
|
|
_appPaths = appPaths;
|
2015-09-14 01:07:54 +02:00
|
|
|
|
_fileSystem = fileSystem;
|
2014-10-11 22:38:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePluginFolder GetFolder()
|
|
|
|
|
{
|
|
|
|
|
var path = Path.Combine(_appPaths.DataPath, "camerauploads");
|
|
|
|
|
|
2015-10-30 16:23:06 +01:00
|
|
|
|
_fileSystem.CreateDirectory(path);
|
2014-10-11 22:38:13 +02:00
|
|
|
|
|
|
|
|
|
return new CameraUploadsFolder
|
|
|
|
|
{
|
|
|
|
|
Path = path
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|