AutoorganizeLog: Fixed error when log empty; re-introduced full reload on task completion
This commit is contained in:
parent
ae331babed
commit
cf64c40413
|
@ -429,17 +429,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||||
GC.Collect(2, GCCollectionMode.Forced, true);
|
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Executes the task.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <param name="progress">The progress.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
private Task ExecuteTask(CancellationToken cancellationToken, IProgress<double> progress)
|
|
||||||
{
|
|
||||||
return Task.Run(async () => await ScheduledTask.Execute(cancellationToken, progress).ConfigureAwait(false), cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Progress_s the progress changed.
|
/// Progress_s the progress changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
using MediaBrowser.Controller.FileOrganization;
|
using MediaBrowser.Common.ScheduledTasks;
|
||||||
|
using MediaBrowser.Controller.FileOrganization;
|
||||||
using MediaBrowser.Controller.Plugins;
|
using MediaBrowser.Controller.Plugins;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Controller.Session;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.FileOrganization;
|
using MediaBrowser.Model.FileOrganization;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Model.Logging;
|
||||||
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.FileOrganization
|
namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
|
@ -20,11 +17,13 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
{
|
{
|
||||||
private readonly IFileOrganizationService _organizationService;
|
private readonly IFileOrganizationService _organizationService;
|
||||||
private readonly ISessionManager _sessionManager;
|
private readonly ISessionManager _sessionManager;
|
||||||
|
private readonly ITaskManager _taskManager;
|
||||||
|
|
||||||
public FileOrganizationNotifier(ILogger logger, IFileOrganizationService organizationService, ISessionManager sessionManager)
|
public FileOrganizationNotifier(ILogger logger, IFileOrganizationService organizationService, ISessionManager sessionManager, ITaskManager taskManager)
|
||||||
{
|
{
|
||||||
_organizationService = organizationService;
|
_organizationService = organizationService;
|
||||||
_sessionManager = sessionManager;
|
_sessionManager = sessionManager;
|
||||||
|
_taskManager = taskManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
@ -33,6 +32,8 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
_organizationService.ItemRemoved += _organizationService_ItemRemoved;
|
_organizationService.ItemRemoved += _organizationService_ItemRemoved;
|
||||||
_organizationService.ItemUpdated += _organizationService_ItemUpdated;
|
_organizationService.ItemUpdated += _organizationService_ItemUpdated;
|
||||||
_organizationService.LogReset += _organizationService_LogReset;
|
_organizationService.LogReset += _organizationService_LogReset;
|
||||||
|
|
||||||
|
_taskManager.TaskCompleted += _taskManager_TaskCompleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _organizationService_LogReset(object sender, EventArgs e)
|
private void _organizationService_LogReset(object sender, EventArgs e)
|
||||||
|
@ -55,12 +56,23 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
_sessionManager.SendMessageToAdminSessions("AutoOrganizeUpdate", (FileOrganizationResult)null, CancellationToken.None);
|
_sessionManager.SendMessageToAdminSessions("AutoOrganizeUpdate", (FileOrganizationResult)null, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void _taskManager_TaskCompleted(object sender, TaskCompletionEventArgs e)
|
||||||
|
{
|
||||||
|
var taskWithKey = e.Task.ScheduledTask as IHasKey;
|
||||||
|
if (taskWithKey != null && taskWithKey.Key == "AutoOrganize")
|
||||||
|
{
|
||||||
|
_sessionManager.SendMessageToAdminSessions("AutoOrganizeUpdate", (FileOrganizationResult)null, CancellationToken.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_organizationService.ItemAdded -= _organizationService_ItemAdded;
|
_organizationService.ItemAdded -= _organizationService_ItemAdded;
|
||||||
_organizationService.ItemRemoved -= _organizationService_ItemRemoved;
|
_organizationService.ItemRemoved -= _organizationService_ItemRemoved;
|
||||||
_organizationService.ItemUpdated -= _organizationService_ItemUpdated;
|
_organizationService.ItemUpdated -= _organizationService_ItemUpdated;
|
||||||
_organizationService.LogReset -= _organizationService_LogReset;
|
_organizationService.LogReset -= _organizationService_LogReset;
|
||||||
|
|
||||||
|
_taskManager.TaskCompleted -= _taskManager_TaskCompleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user