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

78 lines
1.9 KiB
C#
Raw Normal View History

2014-10-11 13:38:13 -07:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
2015-03-01 22:16:29 -07:00
using System;
2014-10-11 13:38:13 -07:00
using System.IO;
using System.Linq;
2015-10-03 21:23:11 -07:00
using CommonIO;
2015-09-13 16:07:54 -07:00
using MediaBrowser.Common.IO;
2014-10-11 13:38:13 -07:00
namespace MediaBrowser.Server.Implementations.Devices
{
public class CameraUploadsFolder : BasePluginFolder
{
public CameraUploadsFolder()
{
Name = "Camera Uploads";
}
public override bool IsVisible(User user)
{
2015-03-01 22:16:29 -07:00
if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
{
return false;
}
2014-10-11 13:38:13 -07:00
return GetChildren(user, true).Any() &&
base.IsVisible(user);
}
public override bool IsHidden
{
get
{
2014-10-30 21:57:24 -07:00
return base.IsHidden || !Children.Any();
2014-10-11 13:38:13 -07: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;
2015-09-13 16:07:54 -07:00
private readonly IFileSystem _fileSystem;
2014-10-11 13:38:13 -07:00
2015-09-13 16:07:54 -07:00
public CameraUploadsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem)
2014-10-11 13:38:13 -07:00
{
_appPaths = appPaths;
2015-09-13 16:07:54 -07:00
_fileSystem = fileSystem;
2014-10-11 13:38:13 -07:00
}
public BasePluginFolder GetFolder()
{
var path = Path.Combine(_appPaths.DataPath, "camerauploads");
2015-09-13 14:32:02 -07:00
_fileSystem.CreateDirectory(path);
2014-10-11 13:38:13 -07:00
return new CameraUploadsFolder
{
Path = path
};
}
}
}