CameraUploadsFolder.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using MediaBrowser.Common.Configuration;
  2. using MediaBrowser.Controller.Entities;
  3. using System;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. using MediaBrowser.Controller.Providers;
  9. using MediaBrowser.Model.Serialization;
  10. namespace MediaBrowser.Server.Implementations.Devices
  11. {
  12. public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView
  13. {
  14. public CameraUploadsFolder()
  15. {
  16. Name = "Camera Uploads";
  17. }
  18. public override bool IsVisible(User user)
  19. {
  20. if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
  21. {
  22. return false;
  23. }
  24. return base.IsVisible(user) && HasChildren();
  25. }
  26. [IgnoreDataMember]
  27. public override string CollectionType
  28. {
  29. get { return Model.Entities.CollectionType.Photos; }
  30. }
  31. public override string GetClientTypeName()
  32. {
  33. return typeof(CollectionFolder).Name;
  34. }
  35. private bool? _hasChildren;
  36. private bool HasChildren()
  37. {
  38. if (!_hasChildren.HasValue)
  39. {
  40. _hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { Parent = this }).Count > 0;
  41. }
  42. return _hasChildren.Value;
  43. }
  44. protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
  45. {
  46. _hasChildren = null;
  47. return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService);
  48. }
  49. [IgnoreDataMember]
  50. public bool EnableUserSpecificView
  51. {
  52. get { return true; }
  53. }
  54. }
  55. }