Merge pull request #1778 from ONLYOFFICE/feature/distributed-task-cancellation-token

Feature/distributed task cancellation token
This commit is contained in:
Pavel Bannov 2023-09-29 03:11:34 -07:00 committed by GitHub
commit 17d75bc474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 11 deletions

View File

@ -53,10 +53,13 @@ public class DistributedTaskProgress : DistributedTask
[ProtoMember(3)]
protected int StepCount { get; set; }
protected CancellationToken CancellationToken { get; set; }
public virtual async Task RunJob(DistributedTask _, CancellationToken cancellationToken)
{
Percentage = 0;
Status = DistributedTaskStatus.Running;
CancellationToken = cancellationToken;
await DoJob();
}

View File

@ -47,8 +47,6 @@ public class ReassignProgressItem : DistributedTaskProgress
private bool _notify;
private bool _deleteProfile;
private CancellationToken _cancellationToken;
public ReassignProgressItem(IServiceScopeFactory serviceScopeFactory)
{
_serviceScopeFactory = serviceScopeFactory;
@ -70,13 +68,6 @@ public class ReassignProgressItem : DistributedTaskProgress
IsCompleted = false;
}
public override async Task RunJob(DistributedTask distributedTask, CancellationToken cancellationToken)
{
_cancellationToken = cancellationToken;
await base.RunJob(distributedTask, cancellationToken);
}
protected override async Task DoJob()
{
await using var scope = _serviceScopeFactory.CreateAsyncScope();
@ -167,7 +158,7 @@ public class ReassignProgressItem : DistributedTaskProgress
PublishChanges();
}
_cancellationToken.ThrowIfCancellationRequested();
CancellationToken.ThrowIfCancellationRequested();
}
private async Task SendSuccessNotifyAsync(UserManager userManager, StudioNotifyService studioNotifyService, MessageService messageService, MessageTarget messageTarget, DisplayUserSettingsHelper displayUserSettingsHelper)

View File

@ -214,7 +214,6 @@ abstract class FileOperation<T, TId> : FileOperation where T : FileOperationData
protected ILinkDao LinkDao { get; private set; }
protected IProviderDao ProviderDao { get; private set; }
protected ILogger Logger { get; private set; }
protected CancellationToken CancellationToken { get; private set; }
protected internal List<TId> Folders { get; private set; }
protected internal List<TId> Files { get; private set; }
protected ExternalShareData CurrentShareData { get; private set; }