From 07072d9f7bf269926a4d7aad580e2e78c444a2cd Mon Sep 17 00:00:00 2001 From: dkanada Date: Thu, 31 Jan 2019 15:12:18 +0900 Subject: move all scheduled tasks and triggers into folders --- .../Tasks/RefreshMediaLibraryTask.cs | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs (limited to 'Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs') diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs new file mode 100644 index 000000000..f6fa64d13 --- /dev/null +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Emby.Server.Implementations.Library; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Tasks; + +namespace Emby.Server.Implementations.ScheduledTasks +{ + /// + /// Class RefreshMediaLibraryTask + /// + public class RefreshMediaLibraryTask : IScheduledTask + { + /// + /// The _library manager + /// + private readonly ILibraryManager _libraryManager; + private readonly IServerConfigurationManager _config; + + /// + /// Initializes a new instance of the class. + /// + /// The library manager. + public RefreshMediaLibraryTask(ILibraryManager libraryManager, IServerConfigurationManager config) + { + _libraryManager = libraryManager; + _config = config; + } + + /// + /// Creates the triggers that define when the task will run + /// + /// IEnumerable{BaseTaskTrigger}. + public IEnumerable GetDefaultTriggers() + { + return new[] { + + // Every so often + new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(12).Ticks} + }; + } + + /// + /// Executes the internal. + /// + /// The cancellation token. + /// The progress. + /// Task. + public Task Execute(CancellationToken cancellationToken, IProgress progress) + { + cancellationToken.ThrowIfCancellationRequested(); + + progress.Report(0); + + return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken); + } + + /// + /// Gets the name. + /// + /// The name. + public string Name => "Scan media library"; + + /// + /// Gets the description. + /// + /// The description. + public string Description => "Scans your media library and refreshes metatata based on configuration."; + + /// + /// Gets the category. + /// + /// The category. + public string Category => "Library"; + + public string Key => "RefreshLibrary"; + } +} -- cgit v1.2.3 From 08ca1337a92c62b68d5a901cdb372b9b6b0a6a02 Mon Sep 17 00:00:00 2001 From: dkanada Date: Thu, 31 Jan 2019 15:20:34 +0900 Subject: unhide several scheduled tasks and add missing properties --- .../ScheduledTasks/Tasks/ChapterImagesTask.cs | 10 +++++++-- .../ScheduledTasks/Tasks/DeleteCacheFileTask.cs | 6 +++--- .../ScheduledTasks/Tasks/DeleteLogFileTask.cs | 6 +++--- .../ScheduledTasks/Tasks/PeopleValidationTask.cs | 10 +++++++-- .../ScheduledTasks/Tasks/PluginUpdateTask.cs | 24 ++++++---------------- .../Tasks/RefreshMediaLibraryTask.cs | 6 ++++++ 6 files changed, 34 insertions(+), 28 deletions(-) (limited to 'Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs') diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs index 5373b4392..a6d43a69a 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs @@ -68,8 +68,6 @@ namespace Emby.Server.Implementations.ScheduledTasks }; } - public string Key => "RefreshChapterImages"; - /// /// Returns the task to be executed /// @@ -178,5 +176,13 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// The category. public string Category => "Library"; + + public string Key => "RefreshChapterImages"; + + public bool IsHidden => false; + + public bool IsEnabled => true; + + public bool IsLogged => true; } } diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index 52077b242..fc9d57e0b 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -164,8 +164,6 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks /// The name. public string Name => "Cache file cleanup"; - public string Key => "DeleteCacheFiles"; - /// /// Gets the description. /// @@ -178,11 +176,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks /// The category. public string Category => "Maintenance"; + public string Key => "DeleteCacheFiles"; + /// /// Gets a value indicating whether this instance is hidden. /// /// true if this instance is hidden; otherwise, false. - public bool IsHidden => true; + public bool IsHidden => false; public bool IsEnabled => true; diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs index a57fe4945..ddb74ef3e 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs @@ -81,8 +81,6 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks return Task.CompletedTask; } - public string Key => "CleanLogFiles"; - /// /// Gets the name of the task /// @@ -101,11 +99,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks /// The category. public string Category => "Maintenance"; + public string Key => "CleanLogFiles"; + /// /// Gets a value indicating whether this instance is hidden. /// /// true if this instance is hidden; otherwise, false. - public bool IsHidden => true; + public bool IsHidden => false; public bool IsEnabled => true; diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs index 68031170f..ebdc6a13e 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs @@ -47,8 +47,6 @@ namespace Emby.Server.Implementations.ScheduledTasks }; } - public string Key => "RefreshPeople"; - /// /// Returns the task to be executed /// @@ -77,5 +75,13 @@ namespace Emby.Server.Implementations.ScheduledTasks /// /// The category. public string Category => "Library"; + + public string Key => "RefreshPeople"; + + public bool IsHidden => false; + + public bool IsEnabled => true; + + public bool IsLogged => true; } } diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs index 62533a017..8e27b0eb8 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs @@ -50,11 +50,6 @@ namespace Emby.Server.Implementations.ScheduledTasks }; } - public string Key - { - get { return "PluginUpdates"; } - } - /// /// Update installed plugins /// @@ -114,26 +109,19 @@ namespace Emby.Server.Implementations.ScheduledTasks /// Gets the name of the task /// /// The name. - public string Name - { - get { return "Check for plugin updates"; } - } + public string Name => "Check for plugin updates"; /// /// Gets the description. /// /// The description. - public string Description - { - get { return "Downloads and installs updates for plugins that are configured to update automatically."; } - } + public string Description => "Downloads and installs updates for plugins that are configured to update automatically."; - public string Category - { - get { return "Application"; } - } + public string Category => "Application"; + + public string Key => "PluginUpdates"; - public bool IsHidden => true; + public bool IsHidden => false; public bool IsEnabled => true; diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs index f6fa64d13..618efd732 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs @@ -77,5 +77,11 @@ namespace Emby.Server.Implementations.ScheduledTasks public string Category => "Library"; public string Key => "RefreshLibrary"; + + public bool IsHidden => false; + + public bool IsEnabled => true; + + public bool IsLogged => true; } } -- cgit v1.2.3 From aadf7676d1d52b67272d5201ccc9835d02a77c0e Mon Sep 17 00:00:00 2001 From: dkanada Date: Thu, 31 Jan 2019 15:23:34 +0900 Subject: remove useless comments --- .../ScheduledTasks/Tasks/ChapterImagesTask.cs | 12 ------------ .../ScheduledTasks/Tasks/DeleteCacheFileTask.cs | 16 ---------------- .../ScheduledTasks/Tasks/DeleteLogFileTask.cs | 16 ---------------- .../ScheduledTasks/Tasks/PeopleValidationTask.cs | 12 ------------ .../ScheduledTasks/Tasks/PluginUpdateTask.cs | 8 -------- .../ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs | 12 ------------ 6 files changed, 76 deletions(-) (limited to 'Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs') diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs index a6d43a69a..81fdb96d2 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs @@ -159,22 +159,10 @@ namespace Emby.Server.Implementations.ScheduledTasks } } - /// - /// Gets the name of the task - /// - /// The name. public string Name => "Chapter image extraction"; - /// - /// Gets the description. - /// - /// The description. public string Description => "Creates thumbnails for videos that have chapters."; - /// - /// Gets the category. - /// - /// The category. public string Category => "Library"; public string Key => "RefreshChapterImages"; diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index fc9d57e0b..6ec83b5c0 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -158,30 +158,14 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks } } - /// - /// Gets the name of the task - /// - /// The name. public string Name => "Cache file cleanup"; - /// - /// Gets the description. - /// - /// The description. public string Description => "Deletes cache files no longer needed by the system"; - /// - /// Gets the category. - /// - /// The category. public string Category => "Maintenance"; public string Key => "DeleteCacheFiles"; - /// - /// Gets a value indicating whether this instance is hidden. - /// - /// true if this instance is hidden; otherwise, false. public bool IsHidden => false; public bool IsEnabled => true; diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs index ddb74ef3e..e468c301a 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs @@ -81,30 +81,14 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks return Task.CompletedTask; } - /// - /// Gets the name of the task - /// - /// The name. public string Name => "Log file cleanup"; - /// - /// Gets the description. - /// - /// The description. public string Description => string.Format("Deletes log files that are more than {0} days old.", ConfigurationManager.CommonConfiguration.LogFileRetentionDays); - /// - /// Gets the category. - /// - /// The category. public string Category => "Maintenance"; public string Key => "CleanLogFiles"; - /// - /// Gets a value indicating whether this instance is hidden. - /// - /// true if this instance is hidden; otherwise, false. public bool IsHidden => false; public bool IsEnabled => true; diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs index ebdc6a13e..d70799c47 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs @@ -58,22 +58,10 @@ namespace Emby.Server.Implementations.ScheduledTasks return _libraryManager.ValidatePeople(cancellationToken, progress); } - /// - /// Gets the name of the task - /// - /// The name. public string Name => "Refresh people"; - /// - /// Gets the description. - /// - /// The description. public string Description => "Updates metadata for actors and directors in your media library."; - /// - /// Gets the category. - /// - /// The category. public string Category => "Library"; public string Key => "RefreshPeople"; diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs index 8e27b0eb8..798dfb2ae 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs @@ -105,16 +105,8 @@ namespace Emby.Server.Implementations.ScheduledTasks progress.Report(100); } - /// - /// Gets the name of the task - /// - /// The name. public string Name => "Check for plugin updates"; - /// - /// Gets the description. - /// - /// The description. public string Description => "Downloads and installs updates for plugins that are configured to update automatically."; public string Category => "Application"; diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs index 618efd732..1a3d85ad7 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs @@ -58,22 +58,10 @@ namespace Emby.Server.Implementations.ScheduledTasks return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken); } - /// - /// Gets the name. - /// - /// The name. public string Name => "Scan media library"; - /// - /// Gets the description. - /// - /// The description. public string Description => "Scans your media library and refreshes metatata based on configuration."; - /// - /// Gets the category. - /// - /// The category. public string Category => "Library"; public string Key => "RefreshLibrary"; -- cgit v1.2.3