support delete per library
This commit is contained in:
parent
6f15141d73
commit
4ef9f68837
|
@ -116,9 +116,11 @@ namespace Emby.Server.Implementations.Dto
|
|||
var channelTuples = new List<Tuple<BaseItemDto, LiveTvChannel>>();
|
||||
|
||||
var index = 0;
|
||||
var allCollectionFolders = _libraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var dto = GetBaseItemDtoInternal(item, options, user, owner);
|
||||
var dto = GetBaseItemDtoInternal(item, options, allCollectionFolders, user, owner);
|
||||
|
||||
var tvChannel = item as LiveTvChannel;
|
||||
if (tvChannel != null)
|
||||
|
@ -173,7 +175,8 @@ namespace Emby.Server.Implementations.Dto
|
|||
{
|
||||
var syncDictionary = GetSyncedItemProgress(options);
|
||||
|
||||
var dto = GetBaseItemDtoInternal(item, options, user, owner);
|
||||
var allCollectionFolders = _libraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
|
||||
var dto = GetBaseItemDtoInternal(item, options, allCollectionFolders, user, owner);
|
||||
var tvChannel = item as LiveTvChannel;
|
||||
if (tvChannel != null)
|
||||
{
|
||||
|
@ -303,7 +306,7 @@ namespace Emby.Server.Implementations.Dto
|
|||
}
|
||||
}
|
||||
|
||||
private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null)
|
||||
private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, List<Folder> allCollectionFolders, User user = null, BaseItem owner = null)
|
||||
{
|
||||
var fields = options.Fields;
|
||||
|
||||
|
@ -472,7 +475,8 @@ namespace Emby.Server.Implementations.Dto
|
|||
|
||||
public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List<BaseItem> taggedItems, Dictionary<string, SyncedItemProgress> syncProgress, User user = null)
|
||||
{
|
||||
var dto = GetBaseItemDtoInternal(item, options, user);
|
||||
var allCollectionFolders = _libraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
|
||||
var dto = GetBaseItemDtoInternal(item, options, allCollectionFolders, user);
|
||||
|
||||
if (taggedItems != null && options.Fields.Contains(ItemFields.ItemCounts))
|
||||
{
|
||||
|
|
|
@ -95,7 +95,9 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
if (parents.Count > 0)
|
||||
{
|
||||
var localizationKey = viewType.Replace("Tv", string.Empty);
|
||||
var localizationKey = string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) ?
|
||||
"Shows" :
|
||||
"Movies";
|
||||
|
||||
list.Add(GetUserView(parents, viewType, localizationKey, string.Empty, user, query.PresetViews, cancellationToken));
|
||||
}
|
||||
|
|
|
@ -1526,13 +1526,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||
|
||||
private void TriggerRefresh(string path)
|
||||
{
|
||||
_logger.Debug("Triggering refresh on {0}", path);
|
||||
_logger.Info("Triggering refresh on {0}", path);
|
||||
|
||||
var item = GetAffectedBaseItem(_fileSystem.GetDirectoryName(path));
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
_logger.Debug("Refreshing recording parent {0}", item.Path);
|
||||
_logger.Info("Refreshing recording parent {0}", item.Path);
|
||||
|
||||
_providerManager.QueueRefresh(item.Id, new MetadataRefreshOptions(_fileSystem)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
"UserDeletedWithName": "\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c {0} \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0451\u043d",
|
||||
"UserConfigurationUpdatedWithName": "\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437-\u043b\u044f {0} \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
|
||||
"MessageServerConfigurationUpdated": "\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
|
||||
"MessageNamedServerConfigurationUpdatedWithValue": "\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (\u0440\u0430\u0437\u0434\u0435\u043b {0}) \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
|
||||
"MessageNamedServerConfigurationUpdatedWithValue": "\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (\u0440\u0430\u0437\u0434\u0435\u043b {0}) \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
|
||||
"MessageApplicationUpdated": "Emby Server \u0431\u044b\u043b \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d",
|
||||
"FailedLoginAttemptWithUserName": "{0} - \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u0430",
|
||||
"AuthenticationSucceededWithUserName": "{0} - \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430",
|
||||
|
|
|
@ -11,6 +11,7 @@ using MediaBrowser.Model.Logging;
|
|||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.System;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace Emby.Server.Implementations.ScheduledTasks
|
||||
{
|
||||
|
@ -86,6 +87,57 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||
}
|
||||
}
|
||||
|
||||
public void RunTaskOnNextStartup(string key)
|
||||
{
|
||||
var path = Path.Combine(ApplicationPaths.CachePath, "startuptasks.txt");
|
||||
|
||||
List<string> lines;
|
||||
|
||||
try
|
||||
{
|
||||
lines = _fileSystem.ReadAllLines(path).ToList() ;
|
||||
}
|
||||
catch
|
||||
{
|
||||
lines = new List<string>();
|
||||
}
|
||||
|
||||
if (!lines.Contains(key, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
lines.Add(key);
|
||||
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
|
||||
_fileSystem.WriteAllLines(path, lines);
|
||||
}
|
||||
}
|
||||
|
||||
private void RunStartupTasks()
|
||||
{
|
||||
var path = Path.Combine(ApplicationPaths.CachePath, "startuptasks.txt");
|
||||
|
||||
List<string> lines;
|
||||
|
||||
try
|
||||
{
|
||||
lines = _fileSystem.ReadAllLines(path).Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
||||
|
||||
foreach (var key in lines)
|
||||
{
|
||||
var task = ScheduledTasks.FirstOrDefault(i => string.Equals(i.ScheduledTask.Key, key, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
QueueScheduledTask(task, new TaskExecutionOptions());
|
||||
}
|
||||
}
|
||||
|
||||
_fileSystem.DeleteFile(path);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels if running and queue.
|
||||
/// </summary>
|
||||
|
@ -235,6 +287,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||
ScheduledTasks = myTasks.ToArray();
|
||||
|
||||
BindToSystemEvent();
|
||||
|
||||
RunStartupTasks();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -477,14 +477,36 @@ namespace MediaBrowser.Controller.Entities
|
|||
locationType != LocationType.Virtual;
|
||||
}
|
||||
|
||||
public virtual bool IsAuthorizedToDelete(User user)
|
||||
public virtual bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return user.Policy.EnableContentDeletion;
|
||||
if (user.Policy.EnableContentDeletion)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var allowed = user.Policy.EnableContentDeletionFromFolders;
|
||||
var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
|
||||
|
||||
foreach (var folder in collectionFolders)
|
||||
{
|
||||
if (allowed.Contains(folder.Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CanDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return CanDelete() && IsAuthorizedToDelete(user, allCollectionFolders);
|
||||
}
|
||||
|
||||
public bool CanDelete(User user)
|
||||
{
|
||||
return CanDelete() && IsAuthorizedToDelete(user);
|
||||
var allCollectionFolders = LibraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
|
||||
return CanDelete(user, allCollectionFolders);
|
||||
}
|
||||
|
||||
public virtual bool CanDownload()
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
}
|
||||
}
|
||||
|
||||
public override bool IsAuthorizedToDelete(User user)
|
||||
public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||
return true;
|
||||
}
|
||||
|
||||
public override bool IsAuthorizedToDelete(User user)
|
||||
public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return user.Policy.EnableLiveTvManagement;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||
return true;
|
||||
}
|
||||
|
||||
public override bool IsAuthorizedToDelete(User user)
|
||||
public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return user.Policy.EnableLiveTvManagement;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
||||
namespace MediaBrowser.Controller.Notifications
|
||||
{
|
||||
|
@ -15,6 +16,8 @@ namespace MediaBrowser.Controller.Notifications
|
|||
/// <returns>Task.</returns>
|
||||
Task SendNotification(NotificationRequest request, CancellationToken cancellationToken);
|
||||
|
||||
Task SendNotification(NotificationRequest request, BaseItem relatedItem, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace MediaBrowser.Controller.Playlists
|
|||
return 1;
|
||||
}
|
||||
|
||||
public override bool IsAuthorizedToDelete(User user)
|
||||
public override bool IsAuthorizedToDelete(User user, List<Folder> allCollectionFolders)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -74,5 +74,7 @@ namespace MediaBrowser.Model.Tasks
|
|||
|
||||
event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
|
||||
event EventHandler<TaskCompletionEventArgs> TaskCompleted;
|
||||
|
||||
void RunTaskOnNextStartup(string key);
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ namespace MediaBrowser.Model.Users
|
|||
public bool EnablePlaybackRemuxing { get; set; }
|
||||
|
||||
public bool EnableContentDeletion { get; set; }
|
||||
public string[] EnableContentDeletionFromFolders { get; set; }
|
||||
public bool EnableContentDownloading { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -73,6 +74,7 @@ namespace MediaBrowser.Model.Users
|
|||
public UserPolicy()
|
||||
{
|
||||
EnableContentDeletion = true;
|
||||
EnableContentDeletionFromFolders = new string[] { };
|
||||
|
||||
EnableSyncTranscoding = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user