sync updates
This commit is contained in:
parent
067b18d067
commit
ac68e0ba41
|
@ -4,7 +4,6 @@ using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Querying;
|
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
|
@ -335,12 +335,30 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||||
trigger.Start(false);
|
trigger.Start(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Task _currentTask;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the task
|
/// Executes the task
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
/// <exception cref="System.InvalidOperationException">Cannot execute a Task that is already running</exception>
|
/// <exception cref="System.InvalidOperationException">Cannot execute a Task that is already running</exception>
|
||||||
public async Task Execute()
|
public async Task Execute()
|
||||||
|
{
|
||||||
|
var task = ExecuteInternal();
|
||||||
|
|
||||||
|
_currentTask = task;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await task.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_currentTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExecuteInternal()
|
||||||
{
|
{
|
||||||
// Cancel the current execution, if any
|
// Cancel the current execution, if any
|
||||||
if (CurrentCancellationTokenSource != null)
|
if (CurrentCancellationTokenSource != null)
|
||||||
|
@ -585,14 +603,60 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||||
{
|
{
|
||||||
DisposeTriggers();
|
DisposeTriggers();
|
||||||
|
|
||||||
if (State == TaskState.Running)
|
var wassRunning = State == TaskState.Running;
|
||||||
|
var startTime = CurrentExecutionStartTime;
|
||||||
|
|
||||||
|
var token = CurrentCancellationTokenSource;
|
||||||
|
if (token != null)
|
||||||
{
|
{
|
||||||
OnTaskCompleted(CurrentExecutionStartTime, DateTime.UtcNow, TaskCompletionStatus.Aborted, null);
|
try
|
||||||
|
{
|
||||||
|
Logger.Debug(Name + ": Cancelling");
|
||||||
|
token.Cancel();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error calling CancellationToken.Cancel();", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var task = _currentTask;
|
||||||
|
if (task != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Logger.Debug(Name + ": Waiting on Task");
|
||||||
|
var exited = Task.WaitAll(new[] { task }, 2000);
|
||||||
|
|
||||||
|
if (exited)
|
||||||
|
{
|
||||||
|
Logger.Debug(Name + ": Task exited");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Debug(Name + ": Timed out waiting for task to stop");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error calling Task.WaitAll();", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentCancellationTokenSource != null)
|
if (token != null)
|
||||||
{
|
{
|
||||||
CurrentCancellationTokenSource.Dispose();
|
try
|
||||||
|
{
|
||||||
|
Logger.Debug(Name + ": Disposing CancellationToken");
|
||||||
|
token.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error calling CancellationToken.Dispose();", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wassRunning)
|
||||||
|
{
|
||||||
|
OnTaskCompleted(startTime, DateTime.UtcNow, TaskCompletionStatus.Aborted, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1098,7 +1098,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await task.Run(innerProgress, cancellationToken);
|
await task.Run(innerProgress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
|
|
@ -285,10 +285,10 @@
|
||||||
"ButtonHelp": "Help",
|
"ButtonHelp": "Help",
|
||||||
"OptionAllowUserToManageServer": "Allow this user to manage the server",
|
"OptionAllowUserToManageServer": "Allow this user to manage the server",
|
||||||
"HeaderFeatureAccess": "Feature Access",
|
"HeaderFeatureAccess": "Feature Access",
|
||||||
"OptionAllowMediaPlayback": "Media playback",
|
"OptionAllowMediaPlayback": "Allow media playback",
|
||||||
"OptionAllowBrowsingLiveTv": "Live TV",
|
"OptionAllowBrowsingLiveTv": "Allow Live TV access",
|
||||||
"OptionAllowDeleteLibraryContent": "Media deletion",
|
"OptionAllowDeleteLibraryContent": "Allow media deletion",
|
||||||
"OptionAllowManageLiveTv": "Live TV recording management",
|
"OptionAllowManageLiveTv": "Allow Live TV recording management",
|
||||||
"OptionAllowRemoteControlOthers": "Allow remote control of other users",
|
"OptionAllowRemoteControlOthers": "Allow remote control of other users",
|
||||||
"OptionAllowRemoteSharedDevices": "Allow remote control of shared devices",
|
"OptionAllowRemoteSharedDevices": "Allow remote control of shared devices",
|
||||||
"OptionAllowRemoteSharedDevicesHelp": "Dlna devices are considered shared until a user begins controlling it.",
|
"OptionAllowRemoteSharedDevicesHelp": "Dlna devices are considered shared until a user begins controlling it.",
|
||||||
|
@ -1362,8 +1362,8 @@
|
||||||
"LabelEnableSingleImageInDidlLimitHelp": "Some devices will not render properly if multiple images are embedded within Didl.",
|
"LabelEnableSingleImageInDidlLimitHelp": "Some devices will not render properly if multiple images are embedded within Didl.",
|
||||||
"TabActivity": "Activity",
|
"TabActivity": "Activity",
|
||||||
"TitleSync": "Sync",
|
"TitleSync": "Sync",
|
||||||
"OptionAllowSyncContent": "Sync",
|
"OptionAllowSyncContent": "Allow Sync",
|
||||||
"OptionAllowContentDownloading": "Media downloading",
|
"OptionAllowContentDownloading": "Allow media downloading",
|
||||||
"NameSeasonUnknown": "Season Unknown",
|
"NameSeasonUnknown": "Season Unknown",
|
||||||
"NameSeasonNumber": "Season {0}",
|
"NameSeasonNumber": "Season {0}",
|
||||||
"LabelNewUserNameHelp": "Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)",
|
"LabelNewUserNameHelp": "Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user