From b748d0784a6b2443ba841190a8ca9b6f0ae62828 Mon Sep 17 00:00:00 2001 From: softworkz Date: Tue, 20 Dec 2016 22:40:07 +0100 Subject: [PATCH] Enhanced sync events --- .../Sync/SyncManager.cs | 27 +++++++++---------- .../Sync/SyncNotificationEntryPoint.cs | 12 +++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Emby.Server.Implementations/Sync/SyncManager.cs b/Emby.Server.Implementations/Sync/SyncManager.cs index 13f60f5eea..061129e5f9 100644 --- a/Emby.Server.Implementations/Sync/SyncManager.cs +++ b/Emby.Server.Implementations/Sync/SyncManager.cs @@ -1042,10 +1042,7 @@ namespace Emby.Server.Implementations.Sync throw new ArgumentException("Operation is not valid for this job item"); } - if (jobItem.Status != SyncJobItemStatus.Synced) - { - jobItem.Status = SyncJobItemStatus.Cancelled; - } + jobItem.Status = SyncJobItemStatus.Cancelled; jobItem.Progress = 0; jobItem.IsMarkedForRemoval = true; @@ -1071,18 +1068,18 @@ namespace Emby.Server.Implementations.Sync _logger.ErrorException("Error deleting directory {0}", ex, path); } - //var jobItemsResult = GetJobItems(new SyncJobItemQuery - //{ - // AddMetadata = false, - // JobId = jobItem.JobId, - // Limit = 0, - // Statuses = new[] { SyncJobItemStatus.Converting, SyncJobItemStatus.Failed, SyncJobItemStatus.Queued, SyncJobItemStatus.ReadyToTransfer, SyncJobItemStatus.Synced, SyncJobItemStatus.Transferring } - //}); + var jobItemsResult = GetJobItems(new SyncJobItemQuery + { + AddMetadata = false, + JobId = jobItem.JobId, + Limit = 0, + Statuses = new[] { SyncJobItemStatus.Converting, SyncJobItemStatus.Queued, SyncJobItemStatus.ReadyToTransfer, SyncJobItemStatus.Synced, SyncJobItemStatus.Transferring } + }); - //if (jobItemsResult.TotalRecordCount == 0) - //{ - // await CancelJob(jobItem.JobId).ConfigureAwait(false); - //} + if (jobItemsResult.TotalRecordCount == 0) + { + await CancelJob(jobItem.JobId).ConfigureAwait(false); + } } public Task MarkJobItemForRemoval(string id) diff --git a/Emby.Server.Implementations/Sync/SyncNotificationEntryPoint.cs b/Emby.Server.Implementations/Sync/SyncNotificationEntryPoint.cs index 46cdb28a4d..06e0e66a91 100644 --- a/Emby.Server.Implementations/Sync/SyncNotificationEntryPoint.cs +++ b/Emby.Server.Implementations/Sync/SyncNotificationEntryPoint.cs @@ -38,6 +38,18 @@ namespace Emby.Server.Implementations.Sync } } + + if (item.Status == SyncJobItemStatus.Cancelled) + { + try + { + await _sessionManager.SendMessageToUserDeviceSessions(item.TargetId, "SyncJobItemCancelled", item, CancellationToken.None).ConfigureAwait(false); + } + catch + { + + } + } } public void Dispose()