diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-11 01:43:42 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-11 01:43:42 -0500 |
| commit | 06afe47ee9716cb210067f3c09cd0c97722bd1c7 (patch) | |
| tree | fa856ef38f03fa051d446bc854e8d6d4b4f24899 /MediaBrowser.Controller/Devices | |
| parent | 369d5e8f09e4e6e7e493bf2049325251942cd215 (diff) | |
update server core project
Diffstat (limited to 'MediaBrowser.Controller/Devices')
| -rw-r--r-- | MediaBrowser.Controller/Devices/CameraUploadsFolder.cs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Devices/CameraUploadsFolder.cs b/MediaBrowser.Controller/Devices/CameraUploadsFolder.cs new file mode 100644 index 000000000..979a929ca --- /dev/null +++ b/MediaBrowser.Controller/Devices/CameraUploadsFolder.cs @@ -0,0 +1,67 @@ +using MediaBrowser.Common.Configuration; +using MediaBrowser.Controller.Entities; +using System; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Model.IO; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Serialization; + +namespace MediaBrowser.Server.Implementations.Devices +{ + public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView + { + public CameraUploadsFolder() + { + Name = "Camera Uploads"; + } + + public override bool IsVisible(User user) + { + if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsVisible(user) && HasChildren(); + } + + [IgnoreDataMember] + public override string CollectionType + { + get { return Model.Entities.CollectionType.Photos; } + } + + public override string GetClientTypeName() + { + return typeof(CollectionFolder).Name; + } + + private bool? _hasChildren; + private bool HasChildren() + { + if (!_hasChildren.HasValue) + { + _hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { ParentId = Id }).Count > 0; + } + + return _hasChildren.Value; + } + + 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); + } + + [IgnoreDataMember] + public bool EnableUserSpecificView + { + get { return true; } + } + } +} |
