-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathAssertFilePartIsDownloadedCommandHandler.cs
More file actions
40 lines (34 loc) · 1.92 KB
/
AssertFilePartIsDownloadedCommandHandler.cs
File metadata and controls
40 lines (34 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using ByteSync.ServerCommon.Interfaces.Repositories;
using ByteSync.ServerCommon.Interfaces.Services;
using MediatR;
using Microsoft.Extensions.Logging;
namespace ByteSync.ServerCommon.Commands.FileTransfers;
public class AssertFilePartIsDownloadedCommandHandler : IRequestHandler<AssertFilePartIsDownloadedRequest>
{
private readonly ICloudSessionsRepository _cloudSessionsRepository;
private readonly ISharedFilesService _sharedFilesService;
private readonly ITransferLocationService _transferLocationService;
private readonly ILogger<AssertFilePartIsDownloadedCommandHandler> _logger;
public AssertFilePartIsDownloadedCommandHandler(ICloudSessionsRepository cloudSessionsRepository,
ISharedFilesService sharedFilesService,
ITransferLocationService transferLocationService,
ILogger<AssertFilePartIsDownloadedCommandHandler> logger)
{
_cloudSessionsRepository = cloudSessionsRepository;
_sharedFilesService = sharedFilesService;
_transferLocationService = transferLocationService;
_logger = logger;
}
public async Task Handle(AssertFilePartIsDownloadedRequest request, CancellationToken cancellationToken)
{
var sessionMemberData = await _cloudSessionsRepository.GetSessionMember(request.SessionId, request.Client);
var sharedFileDefinition = request.TransferParameters.SharedFileDefinition;
var partNumber = request.TransferParameters.PartNumber!.Value;
if (_transferLocationService.IsSharedFileDefinitionAllowed(sessionMemberData, sharedFileDefinition))
{
await _sharedFilesService.AssertFilePartIsDownloaded(sharedFileDefinition, request.Client, partNumber, request.TransferParameters.StorageProvider);
}
_logger.LogDebug("File part download asserted for session {SessionId}, file {FileId}, part {PartNumber}",
request.SessionId, sharedFileDefinition.Id, partNumber);
}
}