jellyfin/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs

74 lines
1.7 KiB
C#
Raw Normal View History

2014-10-11 20:38:13 +00:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
2015-03-02 05:16:29 +00:00
using System;
2014-10-11 20:38:13 +00:00
using System.IO;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Devices
{
public class CameraUploadsFolder : BasePluginFolder
{
public CameraUploadsFolder()
{
Name = "Camera Uploads";
}
public override bool IsVisible(User user)
{
2015-03-02 05:16:29 +00:00
if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
{
return false;
}
2014-10-11 20:38:13 +00:00
return GetChildren(user, true).Any() &&
base.IsVisible(user);
}
public override bool IsHidden
{
get
{
2014-10-31 04:57:24 +00:00
return base.IsHidden || !Children.Any();
2014-10-11 20:38:13 +00:00
}
}
public override bool IsHiddenFromUser(User user)
{
return false;
}
public override string CollectionType
{
get { return Model.Entities.CollectionType.Photos; }
}
public override string GetClientTypeName()
{
return typeof(CollectionFolder).Name;
}
}
public class CameraUploadsDynamicFolder : IVirtualFolderCreator
{
private readonly IApplicationPaths _appPaths;
public CameraUploadsDynamicFolder(IApplicationPaths appPaths)
{
_appPaths = appPaths;
}
public BasePluginFolder GetFolder()
{
var path = Path.Combine(_appPaths.DataPath, "camerauploads");
Directory.CreateDirectory(path);
return new CameraUploadsFolder
{
Path = path
};
}
}
}