mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 21:01:10 +00:00
Adds media library scan progress tracking
This commit is contained in:
1 parent
e8dbf9456c
commit
27fa8e2e4f
87 files changed
+2078
-421
No files matched your search
+82
@@ -0,0 +1,82 @@
|
||||
# Architecture Decision Record (ADR): 0002 - Transaction commit before event publishing in Eventual Consistency Middleware
|
||||
|
||||
## Status
|
||||
**Accepted** (2025-02-18)
|
||||
|
||||
## Context
|
||||
The system requires reliable coordination between database transactions and domain event processing in scenarios involving:
|
||||
|
||||
1. **Background service isolation**: Long-running operations triggered by domain events execute in singleton-hosted services with separate dependency injection scopes.
|
||||
2. **Transaction visibility requirements**: Subsequent operations in child scopes must see committed database state.
|
||||
3. **Eventual consistency needs**: Event handlers may spawn follow-up operations requiring atomic transaction boundaries.
|
||||
|
||||
The previous implementation published domain events *before* transaction commit, causing:
|
||||
|
||||
| Problem | Impact |
|
||||
|---------------------------|---------------------------------------------------------------------------|
|
||||
| Phantom reads | Background services saw pre-commit state via separate DbContext instances |
|
||||
| Stale data actions | Event handlers executed against uncommitted changes |
|
||||
| Scope lifetime mismatch | Singleton services couldn't access request-scoped transaction context |
|
||||
|
||||
## Decision
|
||||
Enforce strict commit-before-publish sequence in `EventualConsistencyMiddleware`:
|
||||
|
||||
```csharp
|
||||
context.Response.OnCompleted(async () =>
|
||||
{
|
||||
if (IsSuccessfulResponse(context))
|
||||
{
|
||||
await transaction.CommitAsync(); // commit FIRST
|
||||
await PublishEvents(publisher, domainEventQueue); // THEN publish
|
||||
}
|
||||
await transaction.DisposeAsync();
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive Outcomes
|
||||
|
||||
| Aspect | Benefit |
|
||||
|-------------------|-------------------------------------------------------------------|
|
||||
| Data visibility | Guarantees event handlers see committed state |
|
||||
| Atomicity | Prevents partial updates from being visible |
|
||||
| Error recovery | Failed event publishing doesn't rollback committed transactions |
|
||||
| Scope alignment | Matches DbContext lifetime with transaction boundaries |
|
||||
|
||||
### Risks and Tradeoffs
|
||||
|
||||
| Risk | Mitigation Strategy |
|
||||
|-------------------------------|-----------------------------------------------------------------------|
|
||||
| Event loss after commit | Implement dead-letter queue with compensation handlers (to be done) |
|
||||
| Non-atomic event publishing | Use outbox pattern for critical events (to be done) |
|
||||
| Transaction timeout | Configure SQL Server `SET LOCK_TIMEOUT` appropriately |
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
### 1. Transactional Outbox Pattern
|
||||
```csharp
|
||||
// store events in outbox table within transaction
|
||||
dbContext.OutboxMessages.AddRange(events);
|
||||
await dbContext.SaveChangesAsync();
|
||||
|
||||
// separate worker publishes from outbox
|
||||
```
|
||||
|
||||
**Rejected** for non-critical events due to:
|
||||
- Added infrastructure complexity (outbox table + worker)
|
||||
- Increased latency for non-critical notifications
|
||||
- Overkill for non-idempotent operations
|
||||
|
||||
### 2. Two-Phase Commit (2PC)
|
||||
```csharp
|
||||
using (TransactionScope scope = new(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
// distributed transaction coordination
|
||||
}
|
||||
```
|
||||
**Rejected** due to:
|
||||
- Unsupported in polyglot persistence environment
|
||||
- Performance overhead from MSDTC coordination
|
||||
- Conflict with cloud-native architecture principles
|
||||
@@ -2,14 +2,6 @@
|
||||
using FluentValidation;
|
||||
using Lumina.Application.Common.Behaviors;
|
||||
using Lumina.Application.Common.DomainEvents;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Cancellation;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.Common;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.WrittenContent.Books;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Queue;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Queue;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Jobs;
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -43,16 +35,7 @@ public static class ApplicationLayerServices
|
||||
services.AddValidatorsFromAssembly(typeof(ApplicationLayerServices).Assembly);
|
||||
|
||||
services.AddScoped<IDomainEventsQueue, DomainEventsQueue>();
|
||||
|
||||
services.AddSingleton<IMediaLibrariesScanQueue, MediaLibrariesScanQueue>();
|
||||
services.AddSingleton<IMediaLibrariesScanCancellationTracker, MediaLibrariesScanCancellationTracker>();
|
||||
services.AddHostedService<MediaLibraryScanJobProcessorJob>();
|
||||
|
||||
services.AddTransient<IFileSystemDiscoveryJob, FileSystemDiscoveryJob>();
|
||||
services.AddTransient<IRepositoryMetadataDiscoveryJob, RepositoryMetadataDiscoveryJob>();
|
||||
services.AddTransient<IHashComparerJob, HashComparerJob>();
|
||||
services.AddTransient<IGoodReadsMetadataScrapJob, GoodReadsMetadataScrapJob>();
|
||||
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Models.Scanning;
|
||||
|
||||
/// <summary>
|
||||
/// Model for tracking media library scans.
|
||||
/// </summary>
|
||||
/// <param name="ScanId">The unique identifier of the media library scan to be tracked.</param>
|
||||
/// <param name="UserId">The unique identifier of the username who initiated the media library scan.</param>
|
||||
public record MediaScanTrackerModel(Guid ScanId, Guid UserId);
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetLibraryScanProgressRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetLibraryScanProgressRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetLibraryScanProgressQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetLibraryScanProgressQuery ToQuery(this GetLibraryScanProgressRequest request)
|
||||
{
|
||||
return new GetLibraryScanProgressQuery(
|
||||
request.LibraryId,
|
||||
request.ScanId
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ public static class LibraryScanEntityMapping
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a collection of converted <see cref="LibraryScan"/>, or an error message.
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a converted <see cref="LibraryScan"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<LibraryScan> ToDomainEntity(this LibraryScanEntity repositoryEntity)
|
||||
{
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="MediaLibraryScanJobProgress"/>.
|
||||
/// </summary>
|
||||
public static class MediaLibraryScanJobProgressMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainValueObject"/> to <see cref="MediaLibraryScanJobProgressResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainValueObject">The domain value object to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static MediaLibraryScanJobProgressResponse ToResponse(this MediaLibraryScanJobProgress domainValueObject)
|
||||
{
|
||||
return new MediaLibraryScanJobProgressResponse(
|
||||
domainValueObject.CompletedItems,
|
||||
domainValueObject.TotalItems,
|
||||
domainValueObject.CurrentOperation,
|
||||
domainValueObject.ProgressPercentage
|
||||
);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="MediaLibraryScanProgress"/>.
|
||||
/// </summary>
|
||||
public static class MediaLibraryScanProgressMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainValueObject"/> to <see cref="MediaLibraryScanProgressResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainValueObject">The domain value object to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static MediaLibraryScanProgressResponse ToResponse(this MediaLibraryScanProgress domainValueObject)
|
||||
{
|
||||
return new MediaLibraryScanProgressResponse(
|
||||
domainValueObject.TotalJobs,
|
||||
domainValueObject.CompletedJobs,
|
||||
domainValueObject.CurrentJobProgress.Value?.ToResponse(),
|
||||
domainValueObject.Status,
|
||||
domainValueObject.OverallProgressPercentage
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,4 +10,4 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibraries
|
||||
/// <summary>
|
||||
/// Command for initiating the scan of all media libraries.
|
||||
/// </summary>
|
||||
public record ScanLibrariesCommand() : IRequest<ErrorOr<IEnumerable<ScanLibraryResponse>>>;
|
||||
public record ScanLibrariesCommand() : IRequest<ErrorOr<IEnumerable<MediaLibraryScanResponse>>>;
|
||||
+4
-4
@@ -25,7 +25,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibraries
|
||||
/// <summary>
|
||||
/// Handler for the command for initiating the scan of all media libraries.
|
||||
/// </summary>
|
||||
public class ScanLibrariesCommandHandler : IRequestHandler<ScanLibrariesCommand, ErrorOr<IEnumerable<ScanLibraryResponse>>>
|
||||
public class ScanLibrariesCommandHandler : IRequestHandler<ScanLibrariesCommand, ErrorOr<IEnumerable<MediaLibraryScanResponse>>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
@@ -57,7 +57,7 @@ public class ScanLibrariesCommandHandler : IRequestHandler<ScanLibrariesCommand,
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async ValueTask<ErrorOr<IEnumerable<ScanLibraryResponse>>> Handle(ScanLibrariesCommand request, CancellationToken cancellationToken)
|
||||
public async ValueTask<ErrorOr<IEnumerable<MediaLibraryScanResponse>>> Handle(ScanLibrariesCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
|
||||
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
||||
@@ -74,7 +74,7 @@ public class ScanLibrariesCommandHandler : IRequestHandler<ScanLibrariesCommand,
|
||||
if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
|
||||
domainEntitiesResult = domainEntitiesResult.Where(libraryResult => libraryResult.Value.UserId.Value == _currentUserService.UserId!.Value);
|
||||
|
||||
List<ScanLibraryResponse> responses = [];
|
||||
List<MediaLibraryScanResponse> responses = [];
|
||||
List<IDomainEvent> domainEvents = [];
|
||||
|
||||
// for each library, start the scan
|
||||
@@ -118,7 +118,7 @@ public class ScanLibrariesCommandHandler : IRequestHandler<ScanLibrariesCommand,
|
||||
// collect all the domain events created during this library scan start
|
||||
domainEvents.AddRange(libraryScanResult.Value.GetDomainEvents());
|
||||
|
||||
responses.Add(new ScanLibraryResponse(libraryScanResult.Value.Id.Value, domainLibraryResult.Value.Id.Value));
|
||||
responses.Add(new MediaLibraryScanResponse(libraryScanResult.Value.Id.Value, domainLibraryResult.Value.Id.Value));
|
||||
}
|
||||
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibrary;
|
||||
/// <param name="Id">The unique identifier of the library to scan.</param>
|
||||
public record ScanLibraryCommand(
|
||||
Guid Id
|
||||
) : IRequest<ErrorOr<ScanLibraryResponse>>;
|
||||
) : IRequest<ErrorOr<MediaLibraryScanResponse>>;
|
||||
+3
-3
@@ -28,7 +28,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibrary;
|
||||
/// <summary>
|
||||
/// Handler for the command for initiating the scan of a media library.
|
||||
/// </summary>
|
||||
public class ScanLibraryCommandHandler : IRequestHandler<ScanLibraryCommand, ErrorOr<ScanLibraryResponse>>
|
||||
public class ScanLibraryCommandHandler : IRequestHandler<ScanLibraryCommand, ErrorOr<MediaLibraryScanResponse>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
@@ -60,7 +60,7 @@ public class ScanLibraryCommandHandler : IRequestHandler<ScanLibraryCommand, Err
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async ValueTask<ErrorOr<ScanLibraryResponse>> Handle(ScanLibraryCommand request, CancellationToken cancellationToken)
|
||||
public async ValueTask<ErrorOr<MediaLibraryScanResponse>> Handle(ScanLibraryCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
|
||||
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
||||
@@ -125,6 +125,6 @@ public class ScanLibraryCommandHandler : IRequestHandler<ScanLibraryCommand, Err
|
||||
foreach (IDomainEvent domainEvent in libraryScanResult.Value.GetDomainEvents())
|
||||
_domainEventsQueue.Enqueue(domainEvent);
|
||||
|
||||
return new ScanLibraryResponse(libraryScanResult.Value.Id.Value, domainLibraryResult.Value.Id.Value);
|
||||
return new MediaLibraryScanResponse(libraryScanResult.Value.Id.Value, domainLibraryResult.Value.Id.Value);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class LibraryScanFailedDomainEventHandler : INotificationHandler<LibraryS
|
||||
|
||||
// mark the media library scan as failed
|
||||
ErrorOr<Success> failScanResult = libraryScanDomainResult.Value.FailScan();
|
||||
// we're going to ignore errors in this point, because scan jobs run in parallel, and two concurrent jobs might trigger this domain event,
|
||||
// we're going to ignore errors in this point, because scan jobs run in parallel, and two concurrent jobs of the same scan might trigger this domain event,
|
||||
// trying to set as failed a scan that has already been marked as failed by a concurrent job
|
||||
if (!failScanResult.IsError)
|
||||
{
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the event raised when a media library scan is finished.
|
||||
/// </summary>
|
||||
public class LibraryScanFinishedDomainEventHandler : INotificationHandler<LibraryScanFinishedDomainEvent>
|
||||
{
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
private readonly IMediaLibrariesScanCancellationTracker _mediaLibrariesScanCancellationTracker;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryScanFinishedDomainEventHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected service for tracking the progress of media library scans.</param>
|
||||
/// <param name="mediaLibrariesScanCancellationTracker">Injected tracker used for canceling media library scans.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
public LibraryScanFinishedDomainEventHandler(
|
||||
IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker,
|
||||
IMediaLibrariesScanCancellationTracker mediaLibrariesScanCancellationTracker,
|
||||
IUnitOfWork unitOfWork)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
_mediaLibrariesScanCancellationTracker = mediaLibrariesScanCancellationTracker;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the event raised when a media library scan is finished.
|
||||
/// </summary>
|
||||
/// <param name="domainEvent">The domain event to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async ValueTask Handle(LibraryScanFinishedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
||||
|
||||
// get the library scan from the repository
|
||||
ErrorOr<LibraryScanEntity?> getLibraryScansResult = await libraryScanRepository.GetByIdAsync(domainEvent.ScanId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryScansResult.IsError)
|
||||
throw new EventualConsistencyException(getLibraryScansResult.FirstError, getLibraryScansResult.Errors);
|
||||
if (getLibraryScansResult.Value is null)
|
||||
throw new EventualConsistencyException(Errors.LibraryScanning.LibraryScanNotFound);
|
||||
|
||||
// convert the repository scan to a domain object
|
||||
ErrorOr<LibraryScan> libraryScanDomainResult = getLibraryScansResult.Value.ToDomainEntity();
|
||||
if (libraryScanDomainResult.IsError)
|
||||
throw new EventualConsistencyException(libraryScanDomainResult.FirstError, libraryScanDomainResult.Errors);
|
||||
|
||||
// mark the media library scan as finished
|
||||
ErrorOr<Success> finishScanResult = libraryScanDomainResult.Value.FinishScan();
|
||||
if (finishScanResult.IsError)
|
||||
throw new EventualConsistencyException(finishScanResult.FirstError, finishScanResult.Errors);
|
||||
|
||||
// update the library scan in the repository
|
||||
ErrorOr<Updated> updateLibraryScanResult = await libraryScanRepository.UpdateAsync(libraryScanDomainResult.Value.ToRepositoryEntity(), cancellationToken).ConfigureAwait(false);
|
||||
if (updateLibraryScanResult.IsError)
|
||||
throw new EventualConsistencyException(updateLibraryScanResult.FirstError, updateLibraryScanResult.Errors);
|
||||
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// mark the scan progress as completed, and remove its cancellation tracking
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanProgress(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId));
|
||||
_mediaLibrariesScanCancellationTracker.RemoveScan(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId));
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the event raised when a media library's scan progress changes.
|
||||
/// </summary>
|
||||
public class LibraryScanJobProgressChangedDomainEventHandler : INotificationHandler<LibraryScanJobProgressChangedDomainEvent>
|
||||
{
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryScanJobProgressChangedDomainEventHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected tracker used for media library scans progress.</param>
|
||||
public LibraryScanJobProgressChangedDomainEventHandler(IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the event raised when a media library's scan progress changes.
|
||||
/// </summary>
|
||||
/// <param name="domainEvent">The domain event to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async ValueTask Handle(LibraryScanJobProgressChangedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanJobProgress(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId), domainEvent.Progress);
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
+14
@@ -1,5 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -12,6 +14,17 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
/// </summary>
|
||||
public class LibraryScanProgressChangedDomainEventHandler : INotificationHandler<LibraryScanProgressChangedDomainEvent>
|
||||
{
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryScanProgressChangedDomainEventHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected tracker used for media library scans progress.</param>
|
||||
public LibraryScanProgressChangedDomainEventHandler(IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the event raised when a media library's scan progress changes.
|
||||
/// </summary>
|
||||
@@ -19,6 +32,7 @@ public class LibraryScanProgressChangedDomainEventHandler : INotificationHandler
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async ValueTask Handle(LibraryScanProgressChangedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanProgress(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId));
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -62,8 +62,7 @@ public class GetLibraryQueryHandler : IRequestHandler<GetLibraryQuery, ErrorOr<L
|
||||
|
||||
// if the user that requested the library is not an Admin or is not the owner of the library, they do not have the right to view it
|
||||
if (getLibraryResult.Value.UserId != _currentUserService.UserId ||
|
||||
(!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false) &&
|
||||
!await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.CanCreateLibraries, cancellationToken)))
|
||||
!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
|
||||
return getLibraryResult.Value.ToResponse();
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Mediator;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Query for getting the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The Id of the media library whose scan progress is requested.</param>
|
||||
/// <param name="ScanId">The Id of the media library scan whose progress is requested.</param>
|
||||
public record GetLibraryScanProgressQuery(
|
||||
Guid LibraryId,
|
||||
Guid ScanId
|
||||
) : IRequest<ErrorOr<MediaLibraryScanProgressResponse>>;
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Enums.Authorization;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
|
||||
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get the progress of a library scan.
|
||||
/// </summary>
|
||||
public class GetLibraryScanProgressQueryHandler : IRequestHandler<GetLibraryScanProgressQuery, ErrorOr<MediaLibraryScanProgressResponse>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryScanProgressQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected service for tracking the progress of media library scans.</param>
|
||||
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
public GetLibraryScanProgressQueryHandler(
|
||||
IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker,
|
||||
IAuthorizationService authorizationService,
|
||||
ICurrentUserService currentUserService,
|
||||
IUnitOfWork unitOfWork)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
_authorizationService = authorizationService;
|
||||
_currentUserService = currentUserService;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the query to get the progress of a library scan.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a <see cref="MediaLibraryScanProgressResponse"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<MediaLibraryScanProgressResponse>> Handle(GetLibraryScanProgressQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// get the library with the specified id from the repository
|
||||
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(request.LibraryId, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError)
|
||||
return getLibraryResult.Errors;
|
||||
else if (getLibraryResult.Value is null)
|
||||
return DomainErrors.Library.LibraryNotFound;
|
||||
|
||||
// if the user that made the request is not an Admin or is not the owner of the library, they do not have the right to view its scan progress
|
||||
if (getLibraryResult.Value.UserId != _currentUserService.UserId ||
|
||||
!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
|
||||
ErrorOr<MediaLibraryScanProgress> getProgressResult = _mediaLibrariesScanProgressTracker.GetScanProgress(
|
||||
MediaLibraryScanCompositeId.Create(ScanId.Create(request.ScanId), UserId.Create(_currentUserService.UserId!.Value)));
|
||||
if (getProgressResult.IsError)
|
||||
return getProgressResult.Errors;
|
||||
|
||||
return getProgressResult.Value.ToResponse();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetLibraryScanProgressQuery"/>.
|
||||
/// </summary>
|
||||
public class GetLibraryScanProgressQueryValidator : AbstractValidator<GetLibraryScanProgressQuery>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryScanProgressQueryValidator"/> class.
|
||||
/// </summary>
|
||||
public GetLibraryScanProgressQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.ScanId)
|
||||
.NotEmpty().WithMessage(Errors.LibraryScanning.LibraryScanIdCannotBeEmpty.Description)
|
||||
.Must(id => id != Guid.Empty).WithMessage(Errors.LibraryScanning.LibraryScanIdCannotBeEmpty.Description);
|
||||
RuleFor(x => x.LibraryId)
|
||||
.NotEmpty().WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description)
|
||||
.Must(id => id != Guid.Empty).WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Infrastructure.Models.Scanning;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Cancellation;
|
||||
|
||||
/// <summary>
|
||||
/// Tracker used for canceling in-memory media library scans.
|
||||
/// </summary>
|
||||
internal class MediaLibrariesScanCancellationTracker : IMediaLibrariesScanCancellationTracker, IDisposable
|
||||
{
|
||||
private readonly ConcurrentDictionary<MediaScanTrackerModel, CancellationTokenSource> _runningScans = new();
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new scan operation for tracking.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The unique identifier of the scan operation to track.</param>
|
||||
/// <param name="userId">The unique identifier of the user who initiated the scan to track.</param>
|
||||
public void RegisterScan(Guid scanId, Guid userId)
|
||||
{
|
||||
_runningScans.TryAdd(new MediaScanTrackerModel(scanId, userId), new CancellationTokenSource());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cancellation token for a scan identified by <paramref name="scanId"/> and <paramref name="userId"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The unique identifier of the scan to get the cancellation token for<./param>
|
||||
/// <param name="userId">The unique identifier of the user who initiated the scan for which to get the cancellation token.</param>
|
||||
/// <returns>A cancellation token for the specified scan.</returns>
|
||||
public CancellationToken GetTokenForScan(Guid scanId, Guid userId)
|
||||
{
|
||||
return _runningScans.TryGetValue(new MediaScanTrackerModel(scanId, userId), out CancellationTokenSource? scan)
|
||||
? scan.Token
|
||||
: CancellationToken.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a scan identified by <paramref name="scanId"/> and <paramref name="userId"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The unique identifier of the scan operation to cancel.</param>
|
||||
/// <param name="userId">The unique identifier of the user requesting the cancellation.</param>
|
||||
public void CancelScan(Guid scanId, Guid userId)
|
||||
{
|
||||
foreach (MediaScanTrackerModel key in _runningScans.Keys)
|
||||
{
|
||||
if (key.ScanId == scanId && key.UserId == userId)
|
||||
{
|
||||
if (_runningScans.TryGetValue(key, out CancellationTokenSource? scan))
|
||||
{
|
||||
scan.Cancel();
|
||||
// remove and dispose after cancellation
|
||||
if (_runningScans.TryRemove(key, out CancellationTokenSource? removedScan))
|
||||
removedScan?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels all active scan operations for a user identified by <paramref name="userId"/>.
|
||||
/// </summary>
|
||||
/// <param name="userId">The unique identifier of the user whose scans should be canceled.</param>
|
||||
public void CancelUserScans(Guid userId)
|
||||
{
|
||||
foreach (MediaScanTrackerModel key in _runningScans.Keys)
|
||||
{
|
||||
if (key.UserId == userId)
|
||||
{
|
||||
if (_runningScans.TryGetValue(key, out CancellationTokenSource? scan))
|
||||
{
|
||||
scan.Cancel();
|
||||
// remove and dispose after cancellation
|
||||
if (_runningScans.TryRemove(key, out CancellationTokenSource? removedScan))
|
||||
removedScan?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the tracker and cancels all media library scans.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
foreach (CancellationTokenSource scan in _runningScans.Values)
|
||||
{
|
||||
scan.Cancel();
|
||||
scan.Dispose();
|
||||
}
|
||||
_runningScans.Clear();
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Media library scan job for comparing hashes.
|
||||
/// </summary>
|
||||
internal sealed class HashComparerJob : MediaLibraryScanJob, IHashComparerJob
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
Console.WriteLine("started file hashing");
|
||||
List<int> ints = [1, 2, 3];
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(1111, cancellationToken).ConfigureAwait(false);
|
||||
Console.WriteLine("ticking");
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
}
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended file hashing");
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, ints, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Canceled;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Media library scan job for retrieving persistence data from any eventual previous scans.
|
||||
/// </summary>
|
||||
internal sealed class RepositoryMetadataDiscoveryJob : MediaLibraryScanJob, IRepositoryMetadataDiscoveryJob
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
Console.WriteLine("started repo discovering");
|
||||
List<int> ints = [1, 2, 3];
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended repo discovering");
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, ints, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Canceled;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Jobs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.WrittenContent.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Media library scan job for retrieving written content metadata from GoodReads.
|
||||
/// </summary>
|
||||
internal sealed class GoodReadsMetadataScrapJob : MediaLibraryScanJob, IGoodReadsMetadataScrapJob
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
Console.WriteLine("started goodreads metadata");
|
||||
List<int> ints = [1, 2, 3];
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended goodreads metadata");
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, ints, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Canceled;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to report the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="LibraryId">The Id of the media library whose scan progress is requested. Required.</param>
|
||||
/// <param name="ScanId">The Id of the media library scan whose progress is requested. Required.</param>
|
||||
[DebuggerDisplay("LibraryId: {LibraryId}, ScanId: {ScanId}")]
|
||||
public record GetLibraryScanProgressRequest(
|
||||
Guid LibraryId,
|
||||
Guid ScanId
|
||||
);
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a media library scan job progress response.
|
||||
/// </summary>
|
||||
/// <param name="CompletedItems">The number of processed scan job items.</param>
|
||||
/// <param name="TotalItems">The total number of scan job items.</param>
|
||||
/// <param name="CurrentOperation">The current processing operation in the scan job.</param>
|
||||
/// <param name="ProgressPercentage">The ratio between the number of processed items and the total number of items to process, as percentage.</param>
|
||||
[DebuggerDisplay("CompletedItems: {CompletedItems} TotalItems: {TotalItems}")]
|
||||
public record MediaLibraryScanJobProgressResponse(
|
||||
int CompletedItems,
|
||||
int TotalItems,
|
||||
string CurrentOperation,
|
||||
decimal ProgressPercentage
|
||||
);
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a media library scan progress response.
|
||||
/// </summary>
|
||||
/// <param name="TotalJobs">The total number of jobs to be processed by the scan.</param>
|
||||
/// <param name="CompletedJobs">The number of jobs that have been processed.</param>
|
||||
/// <param name="CurrentJobProgress">The progress of the currently processing job.</param>
|
||||
/// <param name="Status">The status of the scan.</param>
|
||||
/// <param name="OverallProgressPercentage">The ratio between the number of processed jobs and the total number of jobs to process, as percentage.</param>
|
||||
[DebuggerDisplay("TotalJobs: {TotalJobs} CompletedJobs: {CompletedJobs}")]
|
||||
public record MediaLibraryScanProgressResponse(
|
||||
int TotalJobs,
|
||||
int CompletedJobs,
|
||||
MediaLibraryScanJobProgressResponse? CurrentJobProgress,
|
||||
LibraryScanJobStatus Status,
|
||||
decimal OverallProgressPercentage
|
||||
);
|
||||
+1
-1
@@ -11,7 +11,7 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
/// <param name="ScanId">The unique identifier of the media library scan.</param>
|
||||
/// <param name="LibraryId">The unique identifier of the scanned media library.</param>
|
||||
[DebuggerDisplay("ScanId: {ScanId} LibraryId: {LibraryId}")]
|
||||
public record ScanLibraryResponse(
|
||||
public record MediaLibraryScanResponse(
|
||||
Guid ScanId,
|
||||
Guid LibraryId
|
||||
);
|
||||
@@ -106,6 +106,6 @@ public sealed class UpdateAuditableEntitiesInterceptor : SaveChangesInterceptor
|
||||
|
||||
// set modification properties
|
||||
entry.Entity.UpdatedOnUtc = utcNow;
|
||||
entry.Entity.UpdatedBy = userId;
|
||||
entry.Entity.UpdatedBy = userId ?? Guid.Parse("11111111-1111-1111-1111-111111111111"); // "SYSTEM" user Id
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Scanners;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -49,7 +50,9 @@ public static class DomainLayerServices
|
||||
services.AddScoped<IMediaLibraryScanningService, MediaLibraryScanningService>();
|
||||
services.AddScoped<IBookLibraryTypeScanner, BookLibraryTypeScanner>();
|
||||
services.AddScoped<IMediaLibraryScannerFactory, MediaLibraryScannerFactory>();
|
||||
|
||||
services.AddSingleton<IFileSystem, FileSystem>();
|
||||
services.AddSingleton<IMediaLibrariesScanProgressTracker, MediaLibrariesScanProgressTracker>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,10 @@ namespace Lumina.Domain.Common.Errors;
|
||||
public static partial class Errors
|
||||
{
|
||||
public static class LibraryScanning
|
||||
{
|
||||
{
|
||||
public static Error LibraryScanIdCannotBeEmpty => Error.Validation(description: nameof(LibraryScanIdCannotBeEmpty));
|
||||
public static Error CanOnlyStartPendingScans => Error.Forbidden(description: nameof(CanOnlyStartPendingScans));
|
||||
public static Error CanOnlyCompleteRunningScans => Error.Forbidden(description: nameof(CanOnlyCompleteRunningScans));
|
||||
public static Error CanOnlyCancelRunningScans => Error.Forbidden(description: nameof(CanOnlyCancelRunningScans));
|
||||
public static Error CanOnlyFailRunningScans => Error.Forbidden(description: nameof(CanOnlyFailRunningScans));
|
||||
public static Error ScanIdCannotBeEmpty => Error.Validation(description: nameof(ScanIdCannotBeEmpty));
|
||||
@@ -19,8 +21,11 @@ public static partial class Errors
|
||||
public static Error LibraryAlreadyBeingScanned => Error.Forbidden(description: nameof(LibraryAlreadyBeingScanned));
|
||||
public static Error LibraryScanNotFound => Error.NotFound(description: nameof(LibraryScanNotFound));
|
||||
public static Error TotalScanJobItemsCountMustBePositive => Error.Validation(description: nameof(TotalScanJobItemsCountMustBePositive));
|
||||
public static Error TotalScanJobsCountMustBePositive => Error.Validation(description: nameof(TotalScanJobsCountMustBePositive));
|
||||
public static Error CompletedScanJobItemsCountMustBePositive => Error.Validation(description: nameof(CompletedScanJobItemsCountMustBePositive));
|
||||
public static Error CompletedScanJobsCountMustBePositive => Error.Validation(description: nameof(CompletedScanJobsCountMustBePositive));
|
||||
public static Error CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount => Error.Validation(description: nameof(CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount));
|
||||
public static Error CompletedScanJobsCountCantExceedTotalScanJobsCount => Error.Validation(description: nameof(CompletedScanJobsCountCantExceedTotalScanJobsCount));
|
||||
public static Error ScanJobCurrentOperationCannotBeEmpty => Error.Validation(description: nameof(ScanJobCurrentOperationCannotBeEmpty));
|
||||
}
|
||||
}
|
||||
+9
-5
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -8,14 +10,16 @@ using System.Diagnostics;
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Domain event raised when a libary scan is completed.
|
||||
/// Domain event raised when a libary scan is finished.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
||||
/// <param name="LibraryId">The unique identifier of the library whose scan was completed.</param>
|
||||
/// <param name="ScanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="UserId">The object representing the unique identifier of the user that started the library scan whose progress changes.</param>
|
||||
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||
[DebuggerDisplay("Id: {Id}")]
|
||||
public record LibraryScanCompletedDomainEvent(
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||
public record LibraryScanFinishedDomainEvent(
|
||||
Guid Id,
|
||||
LibraryId LibraryId,
|
||||
ScanId ScanId,
|
||||
UserId UserId,
|
||||
DateTime OccurredOnUtc
|
||||
) : IDomainEvent;
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Domain event raised when a libary's scan job progress changes.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
||||
/// <param name="ScanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="UserId">The object representing the unique identifier of the user that started the library scan whose progress changes.</param>
|
||||
/// <param name="Progress">The object representing the new media library scan job progress.</param>
|
||||
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||
public record LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid Id,
|
||||
ScanId ScanId,
|
||||
UserId UserId,
|
||||
MediaLibraryScanJobProgress Progress,
|
||||
DateTime OccurredOnUtc
|
||||
) : IDomainEvent;
|
||||
+5
-4
@@ -2,6 +2,7 @@
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -12,13 +13,13 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
/// Domain event raised when a libary's scan progress changes.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
||||
/// <param name="ScanId">The unique identifier of the failed media library scan.</param>
|
||||
/// <param name="LibraryId">The unique identifier of the library whose scan progress changes.</param>
|
||||
/// <param name="ScanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="UserId">The object representing the unique identifier of the user that started the library scan whose progress changes.</param>
|
||||
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||
[DebuggerDisplay("Id: {Id}")]
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||
public record LibraryScanProgressChangedDomainEvent(
|
||||
Guid Id,
|
||||
ScanId ScanId,
|
||||
LibraryId LibraryId,
|
||||
UserId UserId,
|
||||
DateTime OccurredOnUtc
|
||||
) : IDomainEvent;
|
||||
+14
@@ -119,6 +119,20 @@ public class LibraryScan : AggregateRoot<ScanId>
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finishes the media library scan.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Success> FinishScan()
|
||||
{
|
||||
if (Status == LibraryScanJobStatus.Running)
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
else
|
||||
return Errors.LibraryScanning.CanOnlyCompleteRunningScans;
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the media library scan.
|
||||
/// </summary>
|
||||
|
||||
+15
-18
@@ -1,5 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System.Threading;
|
||||
#endregion
|
||||
|
||||
@@ -11,30 +11,27 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
public interface IMediaLibrariesScanCancellationTracker
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the cancellation token for a scan identified by <paramref name="scanId"/> and <paramref name="userId"/>.
|
||||
/// Gets the cancellation token for a scan identified by <paramref name="mediaLibraryScanCompositeId"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The unique identifier of the scan to get the cancellation token for.</param>
|
||||
/// <param name="userId">The unique identifier of the user who initiated the scan for which to get the cancellation token.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>A cancellation token for the specified scan.</returns>
|
||||
CancellationToken GetTokenForScan(Guid scanId, Guid userId);
|
||||
CancellationToken GetTokenForScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new scan operation for tracking.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The unique identifier of the scan operation to track.</param>
|
||||
/// <param name="userId">The unique identifier of the user who initiated the scan to track.</param>
|
||||
void RegisterScan(Guid scanId, Guid userId);
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
void RegisterScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a scan operation from tracking.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
void RemoveScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a scan identified by <paramref name="scanId"/> and <paramref name="userId"/>.
|
||||
/// Cancels a scan identified by <paramref name="mediaLibraryScanCompositeId"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The unique identifier of the scan operation to cancel.</param>
|
||||
/// <param name="userId">The unique identifier of the user requesting the cancellation.</param>
|
||||
void CancelScan(Guid scanId, Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels all active scan operations for a user identified by <paramref name="userId"/>.
|
||||
/// </summary>
|
||||
/// <param name="userId">The unique identifier of the user whose scans should be canceled.</param>
|
||||
void CancelUserScans(Guid userId);
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
void CancelScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the media library scan job for persisting data of the current scan. This should always be the last job in the directed acyclic job graph.
|
||||
/// </summary>
|
||||
public interface IRepositoryMetadataSaveJob : IMediaLibraryScanJob
|
||||
{
|
||||
|
||||
}
|
||||
-1
@@ -17,7 +17,6 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
public abstract class MediaLibraryScanJob : IMediaLibraryScanJob
|
||||
{
|
||||
protected int parentsPayloadsExecuted;
|
||||
protected ScanJobProgress? _jobProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library scan that this job is part of.
|
||||
|
||||
+79
-17
@@ -1,11 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Queue;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -20,23 +24,32 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
/// </summary>
|
||||
internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||
{
|
||||
private readonly IMediaLibrariesScanQueue _mediaScanQueue;
|
||||
private readonly IMediaLibraryScannerFactory _libraryScannerFactory;
|
||||
private readonly IMediaLibrariesScanQueue _mediaLibrariesScanQueue;
|
||||
private readonly IMediaLibraryScannerFactory _mediaLibraryScannerFactory;
|
||||
private readonly IMediaLibrariesScanCancellationTracker _mediaLibrariesScanCancellationTracker;
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
private readonly IPublisher _publisher;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaLibraryScanningService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaScanQueue">Injected queue used for processing media libraries scan jobs.</param>
|
||||
/// <param name="libraryScannerFactory">Injected factory for creating media library scanners.</param>
|
||||
/// <param name="mediaLibrariesScanQueue">Injected queue used for processing media libraries scan jobs.</param>
|
||||
/// <param name="mediaLibraryScannerFactory">Injected factory for creating media library scanners.</param>
|
||||
/// <param name="mediaLibrariesScanCancellationTracker">Injected tracker used for canceling media library scans.</param>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected tracker used for media library scans progress.</param>
|
||||
/// <param name="publisher">The domain event publisher used to publish events.</param>
|
||||
public MediaLibraryScanningService(
|
||||
IMediaLibrariesScanQueue mediaScanQueue,
|
||||
IMediaLibraryScannerFactory libraryScannerFactory,
|
||||
IMediaLibrariesScanCancellationTracker mediaLibrariesScanCancellationTracker)
|
||||
IMediaLibrariesScanQueue mediaLibrariesScanQueue,
|
||||
IMediaLibraryScannerFactory mediaLibraryScannerFactory,
|
||||
IMediaLibrariesScanCancellationTracker mediaLibrariesScanCancellationTracker,
|
||||
IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker,
|
||||
IPublisher publisher)
|
||||
{
|
||||
_mediaScanQueue = mediaScanQueue;
|
||||
_libraryScannerFactory = libraryScannerFactory;
|
||||
_mediaLibrariesScanQueue = mediaLibrariesScanQueue;
|
||||
_mediaLibraryScannerFactory = mediaLibraryScannerFactory;
|
||||
_mediaLibrariesScanCancellationTracker = mediaLibrariesScanCancellationTracker;
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
_publisher = publisher;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,25 +66,34 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||
ErrorOr<Success> startScanResult = scan.StartScan();
|
||||
if (startScanResult.IsError)
|
||||
return startScanResult.Errors;
|
||||
|
||||
foreach (IDomainEvent domainEvent in scan.GetDomainEvents())
|
||||
await _publisher!.Publish(domainEvent, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// register the scan in the tracker for cancellation tokens
|
||||
_mediaLibrariesScanCancellationTracker.RegisterScan(scan.Id.Value, scan.UserId!.Value);
|
||||
_mediaLibrariesScanCancellationTracker.RegisterScan(MediaLibraryScanCompositeId.Create(scan.Id, scan.UserId));
|
||||
|
||||
try
|
||||
{
|
||||
// link the user's cancellation token with the scan's token
|
||||
CancellationTokenSource linkedSource = CancellationTokenSource
|
||||
.CreateLinkedTokenSource(cancellationToken, _mediaLibrariesScanCancellationTracker.GetTokenForScan(scan.Id.Value, scan.UserId!.Value));
|
||||
.CreateLinkedTokenSource(cancellationToken, _mediaLibrariesScanCancellationTracker.GetTokenForScan(MediaLibraryScanCompositeId.Create(scan.Id, scan.UserId)));
|
||||
|
||||
// get a media library scanner for the provided media library type
|
||||
IMediaTypeScanner scanner = _libraryScannerFactory.CreateLibraryScanner(libraryType);
|
||||
IMediaTypeScanner scanner = _mediaLibraryScannerFactory.CreateLibraryScanner(libraryType);
|
||||
// get the list of scan jobs for the retrieved scanner
|
||||
List<IMediaLibraryScanJob> jobs = scanner.CreateScanJobsForLibrary(scan.LibraryId, downloadMedatadaFromWeb).ToList();
|
||||
|
||||
// count total jobs in the chain by traversing the job graph
|
||||
int totalJobs = CountTotalJobs(jobs);
|
||||
_mediaLibrariesScanProgressTracker.InitializeScanProgress(MediaLibraryScanCompositeId.Create(scan.Id, scan.UserId), totalJobs);
|
||||
|
||||
// enqueue the jobs on the channel from where they will be processed
|
||||
foreach (IMediaLibraryScanJob job in jobs)
|
||||
{
|
||||
job.ScanId = scan.Id;
|
||||
job.UserId = scan.UserId;
|
||||
await _mediaScanQueue.Writer.WriteAsync(job, linkedSource.Token).ConfigureAwait(false);
|
||||
// set the Id of the scan and of the user initiating the scan to all jobs in the scan job graph
|
||||
SetScanPropertiesForJobChain(job, scan.Id, scan.UserId);
|
||||
await _mediaLibrariesScanQueue.Writer.WriteAsync(job, linkedSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (NotImplementedException) { }
|
||||
@@ -86,7 +108,47 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||
public ErrorOr<Success> CancelScan(LibraryScan scan)
|
||||
{
|
||||
// trigger the process that cancels the jobs of the scan
|
||||
_mediaLibrariesScanCancellationTracker.CancelScan(scan.Id.Value, scan.UserId!.Value);
|
||||
_mediaLibrariesScanCancellationTracker.CancelScan(MediaLibraryScanCompositeId.Create(scan.Id, scan.UserId));
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the scan properties for a job and all its child jobs in a recursive manner.
|
||||
/// </summary>
|
||||
/// <param name="job">The media library scan job whose properties are to be set.</param>
|
||||
/// <param name="scanId">The object representing the unique identifier for the scan.</param>
|
||||
/// <param name="userId">The object representing the unique identifier for the user that initiated the scan.</param>
|
||||
public static void SetScanPropertiesForJobChain(IMediaLibraryScanJob job, ScanId scanId, UserId userId)
|
||||
{
|
||||
job.ScanId = scanId;
|
||||
job.UserId = userId;
|
||||
// recursively set properties for all children
|
||||
foreach (IMediaLibraryScanJob childJob in job.Children)
|
||||
SetScanPropertiesForJobChain(childJob, scanId, userId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts the total number of unique media library scan jobs in a list of root jobs.
|
||||
/// </summary>
|
||||
/// <param name="rootJobs">A list of root media library scan jobs to traverse.</param>
|
||||
/// <returns>The total count of unique media library scan jobs.</returns>
|
||||
private static int CountTotalJobs(List<IMediaLibraryScanJob> rootJobs)
|
||||
{
|
||||
HashSet<IMediaLibraryScanJob> uniqueJobs = [];
|
||||
foreach (IMediaLibraryScanJob job in rootJobs)
|
||||
TraverseJobGraph(job, uniqueJobs);
|
||||
return uniqueJobs.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Traverses the job graph recursively and adds each job to a set of unique jobs.
|
||||
/// </summary>
|
||||
/// <param name="job">The current media library scan job being traversed.</param>
|
||||
/// <param name="uniqueJobs">A hash set that stores unique media library scan jobs.</param>
|
||||
private static void TraverseJobGraph(IMediaLibraryScanJob job, HashSet<IMediaLibraryScanJob> uniqueJobs)
|
||||
{
|
||||
uniqueJobs.Add(job);
|
||||
foreach (IMediaLibraryScanJob child in job.Children)
|
||||
TraverseJobGraph(child, uniqueJobs);
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the tracker used for media library scans progress.
|
||||
/// </summary>
|
||||
public interface IMediaLibrariesScanProgressTracker
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the the progress tracking of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="totalJobs">The total number of jobs that this media library scan contains.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
ErrorOr<Created> InitializeScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, int totalJobs);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the progress tracking of the media library scan by incrementing the number of completed scan jobs.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
ErrorOr<Updated> UpdateScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the progress tracking of the media library scan by incrementing the number of completed items of a scan job.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="progress">The object representing the progress of the media library scan job.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
ErrorOr<Updated> UpdateScanJobProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, MediaLibraryScanJobProgress progress);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
ErrorOr<MediaLibraryScanProgress> GetScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System.Collections.Concurrent;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
|
||||
/// <summary>
|
||||
/// Tracker used for media library scans progress.
|
||||
/// </summary>
|
||||
internal class MediaLibrariesScanProgressTracker : IMediaLibrariesScanProgressTracker
|
||||
{
|
||||
private readonly ConcurrentDictionary<MediaLibraryScanCompositeId, MediaLibraryScanProgress> _scanProgresses = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the the progress tracking of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="totalJobs">The total number of jobs that this media library scan contains.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Created> InitializeScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, int totalJobs)
|
||||
{
|
||||
ErrorOr<MediaLibraryScanJobProgress> createLibraryScanJobProgressResult = MediaLibraryScanJobProgress.Create(0, 0, "Initializing");
|
||||
if (createLibraryScanJobProgressResult.IsError)
|
||||
return createLibraryScanJobProgressResult.Errors;
|
||||
|
||||
ErrorOr<MediaLibraryScanProgress> createScanProgressResult = MediaLibraryScanProgress.Create(
|
||||
completedJobs: 0,
|
||||
totalJobs: totalJobs,
|
||||
LibraryScanJobStatus.Pending,
|
||||
Optional<MediaLibraryScanJobProgress>.Some(createLibraryScanJobProgressResult.Value)
|
||||
);
|
||||
if (createScanProgressResult.IsError)
|
||||
return createScanProgressResult.Errors;
|
||||
|
||||
_scanProgresses[mediaLibraryScanCompositeId] = createScanProgressResult.Value;
|
||||
|
||||
return Result.Created;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the progress tracking of the media library scan by incrementing the number of completed scan jobs.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Updated> UpdateScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
{
|
||||
if (_scanProgresses.TryGetValue(mediaLibraryScanCompositeId, out MediaLibraryScanProgress? progress))
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgress> createScanProgressResult = MediaLibraryScanProgress.Create(
|
||||
progress.CompletedJobs + 1,
|
||||
progress.TotalJobs,
|
||||
progress.CompletedJobs + 1 == progress.TotalJobs ? LibraryScanJobStatus.Completed : LibraryScanJobStatus.Running,
|
||||
progress.CurrentJobProgress
|
||||
);
|
||||
if (createScanProgressResult.IsError)
|
||||
return createScanProgressResult.Errors;
|
||||
|
||||
_scanProgresses[mediaLibraryScanCompositeId] = createScanProgressResult.Value;
|
||||
}
|
||||
return Result.Updated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the progress tracking of the media library scan by incrementing the number of completed items of a scan job.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="progress">The object representing the progress of the media library scan job.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Updated> UpdateScanJobProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, MediaLibraryScanJobProgress progress)
|
||||
{
|
||||
if (_scanProgresses.TryGetValue(mediaLibraryScanCompositeId, out MediaLibraryScanProgress? scanProgress))
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgress> createScanProgressResult = MediaLibraryScanProgress.Create(
|
||||
scanProgress.CompletedJobs,
|
||||
scanProgress.TotalJobs,
|
||||
scanProgress.Status,
|
||||
Optional<MediaLibraryScanJobProgress>.Some(progress)
|
||||
);
|
||||
if (createScanProgressResult.IsError)
|
||||
return createScanProgressResult.Errors;
|
||||
|
||||
_scanProgresses[mediaLibraryScanCompositeId] = createScanProgressResult.Value;
|
||||
return Result.Updated;
|
||||
}
|
||||
return Errors.LibraryScanning.LibraryScanNotFound;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
public ErrorOr<MediaLibraryScanProgress> GetScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
{
|
||||
if (_scanProgresses.TryGetValue(mediaLibraryScanCompositeId, out MediaLibraryScanProgress? progress))
|
||||
return progress;
|
||||
return Errors.LibraryScanning.LibraryScanNotFound;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
|
||||
/// <summary>
|
||||
/// Interface defining a factory for creating media library scanners.
|
||||
+1
-1
@@ -5,7 +5,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
|
||||
/// <summary>
|
||||
/// Interface defining a media library scanner for a specific media library type.
|
||||
+1
-1
@@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
|
||||
/// <summary>
|
||||
/// Defines a factory for creating media library scanners.
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the composite unique identifier of a media library scan.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||
public sealed class MediaLibraryScanCompositeId : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the object representing the unique identifier of the media library scan to be tracked.
|
||||
/// </summary>
|
||||
public ScanId ScanId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object representing the unique identifier of the username who initiated the media library scan.
|
||||
/// </summary>
|
||||
public UserId UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaLibraryScanCompositeId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The object representing the unique identifier of the media library scan to be tracked.</param>
|
||||
/// <param name="userId">The object representing the unique identifier of the username who initiated the media library scan.</param>
|
||||
private MediaLibraryScanCompositeId(ScanId scanId, UserId userId)
|
||||
{
|
||||
ScanId = scanId;
|
||||
UserId = userId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaLibraryScanCompositeId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The object representing the unique identifier of the media library scan to be tracked.</param>
|
||||
/// <param name="userId">The object representing the unique identifier of the username who initiated the media library scan.</param>
|
||||
/// <returns>The created <see cref="MediaLibraryScanCompositeId"/> instance.</returns>
|
||||
public static MediaLibraryScanCompositeId Create(ScanId scanId, UserId userId)
|
||||
{
|
||||
return new MediaLibraryScanCompositeId(scanId, userId);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return ScanId;
|
||||
yield return UserId;
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -12,7 +12,7 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
/// Value Object representing a progress snapshot of a media library scan job.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("CompletedItems: {CompletedItems}; TotalItems: {TotalItems}; CurrentOperation: {CurrentOperation}")]
|
||||
public sealed class ScanJobProgress : ValueObject
|
||||
public sealed class MediaLibraryScanJobProgress : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the number of completed items of the media library scan job.
|
||||
@@ -32,15 +32,15 @@ public sealed class ScanJobProgress : ValueObject
|
||||
/// <summary>
|
||||
/// Gets the ratio between the total number and the completed number of items, as a percentage.
|
||||
/// </summary>
|
||||
public decimal ProgressPercentage => CompletedItems * 100.0m / TotalItems;
|
||||
public decimal ProgressPercentage => TotalItems > 0 ? CompletedItems * 100.0m / TotalItems : 0;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScanJobProgress"/> class.
|
||||
/// Initializes a new instance of the <see cref="MediaLibraryScanJobProgress"/> class.
|
||||
/// </summary>
|
||||
/// <param name="completedItems">The number of completed items of the media library scan job.</param>
|
||||
/// <param name="totalItems">The total number of items of the media library scan job.</param>
|
||||
/// <param name="currentOperation">The current operation being performed by the media library scan job.</param>
|
||||
private ScanJobProgress(int completedItems, int totalItems, string currentOperation)
|
||||
private MediaLibraryScanJobProgress(int completedItems, int totalItems, string currentOperation)
|
||||
{
|
||||
CompletedItems = completedItems;
|
||||
TotalItems = totalItems;
|
||||
@@ -48,17 +48,17 @@ public sealed class ScanJobProgress : ValueObject
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ScanJobProgress"/> class.
|
||||
/// Creates a new instance of the <see cref="MediaLibraryScanJobProgress"/> class.
|
||||
/// </summary>
|
||||
/// <param name="completedItems">The number of completed items of the media library scan job.</param>
|
||||
/// <param name="totalItems">The total number of items of the media library scan job.</param>
|
||||
/// <param name="currentOperation">The current operation being performed by the media library scan job.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="ScanJobProgress"/>, or an error message.
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="MediaLibraryScanJobProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<ScanJobProgress> Create(int completedItems, int totalItems, string currentOperation)
|
||||
public static ErrorOr<MediaLibraryScanJobProgress> Create(int completedItems, int totalItems, string currentOperation)
|
||||
{
|
||||
if (totalItems <= 0)
|
||||
if (totalItems < 0)
|
||||
return Errors.LibraryScanning.TotalScanJobItemsCountMustBePositive;
|
||||
if (completedItems < 0)
|
||||
return Errors.LibraryScanning.CompletedScanJobItemsCountMustBePositive;
|
||||
@@ -66,7 +66,7 @@ public sealed class ScanJobProgress : ValueObject
|
||||
return Errors.LibraryScanning.CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount;
|
||||
if (string.IsNullOrWhiteSpace(currentOperation))
|
||||
return Errors.LibraryScanning.ScanJobCurrentOperationCannotBeEmpty;
|
||||
return new ScanJobProgress(completedItems, totalItems, currentOperation);
|
||||
return new MediaLibraryScanJobProgress(completedItems, totalItems, currentOperation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object representing a progress snapshot of a media library scan.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("CompletedJobs: {CompletedJobs}; TotalJobs: {TotalJobs}; CurrentJobProgress: {CurrentJobProgress}")]
|
||||
public sealed class MediaLibraryScanProgress : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the number of completed jobs of the media library scan job.
|
||||
/// </summary>
|
||||
public int CompletedJobs { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of jobs of the media library scan job.
|
||||
/// </summary>
|
||||
public int TotalJobs { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional current job progress of the media library scan.
|
||||
/// </summary>
|
||||
public Optional<MediaLibraryScanJobProgress> CurrentJobProgress { get; } = Optional<MediaLibraryScanJobProgress>.None();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status of the media library scan.
|
||||
/// </summary>
|
||||
public LibraryScanJobStatus Status { get; } = LibraryScanJobStatus.Pending;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ratio between the total number and the completed number of jobs, as a percentage.
|
||||
/// </summary>
|
||||
public decimal OverallProgressPercentage => TotalJobs > 0 ? CompletedJobs * 100.0m / TotalJobs : 0;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaLibraryScanProgress"/> class.
|
||||
/// </summary>
|
||||
/// <param name="completedJobs">The number of completed jobs of the media library scan job.</param>
|
||||
/// <param name="totalJobs">The total number of jobs of the media library scan job.</param>
|
||||
/// <param name="status">The status of the media library scan.</param>
|
||||
/// <param name="currentJobProgress">The optional current job progress of the media library scan.</param>
|
||||
private MediaLibraryScanProgress(int completedJobs, int totalJobs, LibraryScanJobStatus status, Optional<MediaLibraryScanJobProgress> currentJobProgress)
|
||||
{
|
||||
CompletedJobs = completedJobs;
|
||||
TotalJobs = totalJobs;
|
||||
CurrentJobProgress = currentJobProgress;
|
||||
Status = status;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaLibraryScanProgress"/> class.
|
||||
/// </summary>
|
||||
/// <param name="completedJobs">The number of completed jobs of the media library scan job.</param>
|
||||
/// <param name="totalJobs">The total number of jobs of the media library scan job.</param>
|
||||
/// <param name="status">The status of the media library scan.</param>
|
||||
/// <param name="currentJobProgress">The optional current job progress of the media library scan.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<MediaLibraryScanProgress> Create(int completedJobs, int totalJobs, LibraryScanJobStatus status, Optional<MediaLibraryScanJobProgress> currentJobProgress)
|
||||
{
|
||||
if (totalJobs <= 0)
|
||||
return Errors.LibraryScanning.TotalScanJobsCountMustBePositive;
|
||||
if (completedJobs < 0)
|
||||
return Errors.LibraryScanning.CompletedScanJobsCountMustBePositive;
|
||||
if (completedJobs > totalJobs)
|
||||
return Errors.LibraryScanning.CompletedScanJobsCountCantExceedTotalScanJobsCount;
|
||||
|
||||
return new MediaLibraryScanProgress(completedJobs, totalJobs, status, currentJobProgress);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return CompletedJobs;
|
||||
yield return TotalJobs;
|
||||
yield return Status;
|
||||
yield return CurrentJobProgress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customized ToString() method.
|
||||
/// </summary>
|
||||
/// <returns>Custom string value showing relevant data for current class.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"CompletedJobs: {CompletedJobs}; TotalJobs: {TotalJobs}; CurrentJobProgress: {CurrentJobProgress}";
|
||||
}
|
||||
}
|
||||
+10
@@ -35,6 +35,7 @@ internal class BookLibraryTypeScanner : IBookLibraryTypeScanner
|
||||
IRepositoryMetadataDiscoveryJob repositoryMetadataDiscoveryJob = _mediaScanJobFactory.CreateJob<IRepositoryMetadataDiscoveryJob>(libraryId);
|
||||
IHashComparerJob hashComparerJob = _mediaScanJobFactory.CreateJob<IHashComparerJob>(libraryId);
|
||||
IGoodReadsMetadataScrapJob goodReadsMetadataScrapJob = _mediaScanJobFactory.CreateJob<IGoodReadsMetadataScrapJob>(libraryId);
|
||||
IRepositoryMetadataSaveJob repositoryMetadataSaveJob = _mediaScanJobFactory.CreateJob<IRepositoryMetadataSaveJob>(libraryId);
|
||||
|
||||
// establish the hierarchical relationships between jobs
|
||||
fileSystemDiscoveryJob.AddChild(hashComparerJob);
|
||||
@@ -46,7 +47,16 @@ internal class BookLibraryTypeScanner : IBookLibraryTypeScanner
|
||||
if (downloadMedatadaFromWeb)
|
||||
{
|
||||
hashComparerJob.AddChild(goodReadsMetadataScrapJob);
|
||||
goodReadsMetadataScrapJob.AddChild(repositoryMetadataSaveJob);
|
||||
|
||||
goodReadsMetadataScrapJob.AddParent(hashComparerJob);
|
||||
repositoryMetadataSaveJob.AddParent(goodReadsMetadataScrapJob);
|
||||
}
|
||||
else // TODO: perform some action with local files?
|
||||
{
|
||||
hashComparerJob.AddChild(repositoryMetadataSaveJob);
|
||||
|
||||
repositoryMetadataSaveJob.AddParent(hashComparerJob);
|
||||
}
|
||||
|
||||
// return the top level jobs that will be triggered when the scan will be started
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Scanners;
|
||||
|
||||
@@ -22,8 +22,4 @@
|
||||
<PackageReference Include="Mediator.Abstractions" Version="3.0.0-preview.27" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Core\BoundedContexts\LibraryManagementBoundedContext\LibraryScanAggregate\Services\Progress\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -5,10 +5,18 @@ using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.Over18;
|
||||
using Lumina.Application.Common.Infrastructure.Security;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Queue;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Queue;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Jobs;
|
||||
using Lumina.Infrastructure.Core.Authentication;
|
||||
using Lumina.Infrastructure.Core.Authorization;
|
||||
using Lumina.Infrastructure.Core.Authorization.Policies.Common.Factory;
|
||||
using Lumina.Infrastructure.Core.Authorization.Policies.Over18;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Cancellation;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.WrittenContent.Books;
|
||||
using Lumina.Infrastructure.Core.Security;
|
||||
using Lumina.Infrastructure.Core.Time;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -46,6 +54,17 @@ public static class InfrastructureLayerServices
|
||||
services.AddScoped<IOver18Policy, Over18Policy>();
|
||||
services.AddScoped<IAuthorizationPolicyFactory, AuthorizationPolicyFactory>();
|
||||
services.AddScoped<IAuthorizationService, AuthorizationService>();
|
||||
|
||||
// media library scanning
|
||||
services.AddSingleton<IMediaLibrariesScanQueue, MediaLibrariesScanQueue>();
|
||||
services.AddSingleton<IMediaLibrariesScanCancellationTracker, MediaLibrariesScanCancellationTracker>();
|
||||
services.AddHostedService<MediaLibraryScanJobProcessorJob>();
|
||||
|
||||
services.AddTransient<IFileSystemDiscoveryJob, FileSystemDiscoveryJob>();
|
||||
services.AddTransient<IRepositoryMetadataDiscoveryJob, RepositoryMetadataDiscoveryJob>();
|
||||
services.AddTransient<IHashComparerJob, HashComparerJob>();
|
||||
services.AddTransient<IGoodReadsMetadataScrapJob, GoodReadsMetadataScrapJob>();
|
||||
services.AddTransient<IRepositoryMetadataSaveJob, RepositoryMetadataSaveJob>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Cancellation;
|
||||
|
||||
/// <summary>
|
||||
/// Tracker used for canceling in-memory media library scans.
|
||||
/// </summary>
|
||||
internal class MediaLibrariesScanCancellationTracker : IMediaLibrariesScanCancellationTracker, IDisposable
|
||||
{
|
||||
private readonly ConcurrentDictionary<MediaLibraryScanCompositeId, CancellationTokenSource> _runningScans = new();
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new scan operation for tracking.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
public void RegisterScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
{
|
||||
_runningScans.TryAdd(mediaLibraryScanCompositeId, new CancellationTokenSource());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a scan operation from tracking.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
public void RemoveScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
{
|
||||
if (_runningScans.TryGetValue(mediaLibraryScanCompositeId, out CancellationTokenSource? scan))
|
||||
{
|
||||
scan.Cancel();
|
||||
// remove and dispose after cancellation
|
||||
if (_runningScans.TryRemove(mediaLibraryScanCompositeId, out CancellationTokenSource? removedScan))
|
||||
removedScan?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cancellation token for a scan identified by <paramref name="mediaLibraryScanCompositeId"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>A cancellation token for the specified scan.</returns>
|
||||
public CancellationToken GetTokenForScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
{
|
||||
return _runningScans.TryGetValue(mediaLibraryScanCompositeId, out CancellationTokenSource? scan)
|
||||
? scan.Token
|
||||
: CancellationToken.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a scan identified by <paramref name="mediaLibraryScanCompositeId"/>.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
public void CancelScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
{
|
||||
if (_runningScans.TryGetValue(mediaLibraryScanCompositeId, out CancellationTokenSource? scan))
|
||||
{
|
||||
scan.Cancel();
|
||||
// remove and dispose after cancellation
|
||||
if (_runningScans.TryRemove(mediaLibraryScanCompositeId, out CancellationTokenSource? removedScan))
|
||||
removedScan?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the tracker and cancels all media library scans.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
foreach (CancellationTokenSource scan in _runningScans.Values)
|
||||
{
|
||||
scan.Cancel();
|
||||
scan.Dispose();
|
||||
}
|
||||
_runningScans.Clear();
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+67
-61
@@ -3,9 +3,7 @@ using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DomainEvents;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.Payloads;
|
||||
using Lumina.Domain.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -16,6 +14,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Payloads;
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
@@ -24,7 +23,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.Common;
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Media library scan job for discovering file system items.
|
||||
@@ -59,74 +58,81 @@ internal sealed class FileSystemDiscoveryJob : MediaLibraryScanJob, IFileSystemD
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
|
||||
Console.WriteLine("started file discovering");
|
||||
// see docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details:
|
||||
await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope();
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
// this needs to be wrapped in a task because even though this job is processed in a "fire and forget" async manner, it still does synchronous
|
||||
// file system processing that takes time, and would block the processing of scan jobs in the in-memory queue
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
await Task.Delay(25000);
|
||||
Console.WriteLine("started file discovering");
|
||||
// see docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details:
|
||||
await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope();
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
|
||||
// convert it to a domain object
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial progress of the scan job
|
||||
ErrorOr<ScanJobProgress> scanJobProgressResult = ScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "DiscoveringFiles");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
_jobProgress = scanJobProgressResult.Value;
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Console.WriteLine($"Reporting job progress in file discovery. Total: {_jobProgress.TotalItems}; Completed: {_jobProgress.CompletedItems}; Current: {_jobProgress.CurrentOperation}");
|
||||
// recursively get the file system tree for each of the media library content locations
|
||||
List<FileSystemTreeNode> contentLocationTrees = [];
|
||||
foreach (FileSystemPathId contentLocation in domainLibraryResult.Value.ContentLocations)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ErrorOr<FileSystemTreeNode> treeResult = BuildTree(contentLocation, includeHiddenElements: true, cancellationToken);
|
||||
if (treeResult.IsError)
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
// handle errors, maybe:
|
||||
// Status = LibraryScanJobStatus.Failed;
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
contentLocationTrees.Add(treeResult.Value);
|
||||
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = ScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "DiscoveringFiles");
|
||||
// convert it to a domain object
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial progress of the scan job
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "DiscoveringFiles");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
Console.WriteLine("ended file discovering");
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, contentLocationTrees, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// recursively get the file system tree for each of the media library content locations
|
||||
List<FileSystemTreeNode> contentLocationTrees = [];
|
||||
foreach (FileSystemPathId contentLocation in domainLibraryResult.Value.ContentLocations)
|
||||
{
|
||||
await Task.Delay(5000);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ErrorOr<FileSystemTreeNode> treeResult = BuildTree(contentLocation, includeHiddenElements: true, cancellationToken);
|
||||
if (treeResult.IsError)
|
||||
{
|
||||
// handle errors, maybe:
|
||||
// Status = LibraryScanJobStatus.Failed;
|
||||
}
|
||||
else
|
||||
contentLocationTrees.Add(treeResult.Value);
|
||||
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "DiscoveringFiles");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, increment the number of processed jobs progress
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Console.WriteLine("ended file discovering");
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, contentLocationTrees, cancellationToken).ConfigureAwait(false);
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Media library scan job for comparing hashes.
|
||||
/// </summary>
|
||||
internal sealed class HashComparerJob : MediaLibraryScanJob, IHashComparerJob
|
||||
{
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HashComparerJob"/> class.
|
||||
/// </summary>
|
||||
/// <param name="serviceScopeFactory">
|
||||
/// Injected factory for creating scopes in which services are requested.
|
||||
/// See docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details.
|
||||
/// </param>
|
||||
public HashComparerJob(IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
Console.WriteLine("started file hashing");
|
||||
// see docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details:
|
||||
await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope();
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// convert it to a domain object
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial progress of the scan job
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "ComparingFileHashes");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<int> ints = [1, 2, 3];
|
||||
foreach (int nr in ints)
|
||||
{
|
||||
await Task.Delay(5400);
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "ComparingFileHashes");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, increment the number of processed jobs progress
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended file hashing");
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, ints, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Canceled;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Media library scan job for retrieving persistence data from any eventual previous scans.
|
||||
/// </summary>
|
||||
internal sealed class RepositoryMetadataDiscoveryJob : MediaLibraryScanJob, IRepositoryMetadataDiscoveryJob
|
||||
{
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RepositoryMetadataDiscoveryJob"/> class.
|
||||
/// </summary>
|
||||
/// <param name="serviceScopeFactory">
|
||||
/// Injected factory for creating scopes in which services are requested.
|
||||
/// See docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details.
|
||||
/// </param>
|
||||
public RepositoryMetadataDiscoveryJob(IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
// this needs to be wrapped in a task because even though this job is processed in a "fire and forget" async manner, it still does synchronous
|
||||
// file system processing that takes time, and would block the processing of scan jobs in the in-memory queue
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
Console.WriteLine("started repo discovering");
|
||||
// see docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details:
|
||||
await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope();
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// convert it to a domain object
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial progress of the scan job
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "RetrievingPastScanData");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<int> ints = [1, 2, 3];
|
||||
foreach (int nr in ints)
|
||||
{
|
||||
await Task.Delay(5400);
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "RetrievingPastScanData");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, increment the number of processed jobs progress
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended repo discovering");
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, ints, cancellationToken).ConfigureAwait(false);
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Canceled;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Media library scan job for persisting data of the current scan. This should always be the last job in the directed acyclic job graph.
|
||||
/// </summary>
|
||||
internal sealed class RepositoryMetadataSaveJob : MediaLibraryScanJob, IRepositoryMetadataSaveJob
|
||||
{
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RepositoryMetadataSaveJob"/> class.
|
||||
/// </summary>
|
||||
/// <param name="serviceScopeFactory">
|
||||
/// Injected factory for creating scopes in which services are requested.
|
||||
/// See docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details.
|
||||
/// </param>
|
||||
public RepositoryMetadataSaveJob(IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
// this needs to be wrapped in a task because even though this job is processed in a "fire and forget" async manner, it still does synchronous
|
||||
// file system processing that takes time, and would block the processing of scan jobs in the in-memory queue
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
Console.WriteLine("started repo saving");
|
||||
// see docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details:
|
||||
await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope();
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// convert it to a domain object
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial progress of the scan job
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "SavingScanData");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<int> ints = [1, 2, 3];
|
||||
foreach (int nr in ints)
|
||||
{
|
||||
await Task.Delay(5400);
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "SavingScanData");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, and it's the last in the chain, the scan is completed
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
await publisher!.Publish(new LibraryScanFinishedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Console.WriteLine("ended repo saving");
|
||||
// this should always be the last job in the directed acyclic job graph, so no linked child to call further
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Canceled;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.Payloads;
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Payloads;
|
||||
|
||||
/// <summary>
|
||||
/// Generic file system node.
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Jobs;
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.WrittenContent.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Media library scan job for retrieving written content metadata from GoodReads.
|
||||
/// </summary>
|
||||
internal sealed class GoodReadsMetadataScrapJob : MediaLibraryScanJob, IGoodReadsMetadataScrapJob
|
||||
{
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GoodReadsMetadataScrapJob"/> class.
|
||||
/// </summary>
|
||||
/// <param name="serviceScopeFactory">
|
||||
/// Injected factory for creating scopes in which services are requested.
|
||||
/// See docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details.
|
||||
/// </param>
|
||||
public GoodReadsMetadataScrapJob(IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
Console.WriteLine("started goodreads metadata");
|
||||
// see docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details:
|
||||
await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope();
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// convert it to a domain object
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial progress of the scan job
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "GoodReadsDownload");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<int> ints = [1, 2, 3];
|
||||
foreach (int nr in ints)
|
||||
{
|
||||
await Task.Delay(5400);
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "GoodReadsMetadataDownload");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, increment the number of processed jobs progress
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended goodreads metadata");
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, ints, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Status = LibraryScanJobStatus.Canceled;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-6
@@ -11,12 +11,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Queu
|
||||
/// </summary>
|
||||
internal class MediaLibrariesScanQueue : IMediaLibrariesScanQueue
|
||||
{
|
||||
private readonly Channel<IMediaLibraryScanJob> _channel = Channel.CreateUnbounded<IMediaLibraryScanJob>(new UnboundedChannelOptions
|
||||
{
|
||||
SingleWriter = false,
|
||||
SingleReader = false,
|
||||
AllowSynchronousContinuations = true
|
||||
});
|
||||
private readonly Channel<IMediaLibraryScanJob> _channel = Channel.CreateUnbounded<IMediaLibraryScanJob>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the writer for the queue, allowing producers to enqueue <see cref="IMediaLibraryScanJob"/> instances.
|
||||
+3
-2
@@ -3,6 +3,7 @@ using Lumina.Application.Common.Utilities;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Queue;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Threading;
|
||||
@@ -23,7 +24,7 @@ internal sealed class MediaLibraryScanJobProcessorJob : BackgroundService
|
||||
/// Initializes a new instance of the <see cref="MediaLibraryScanJobProcessorJob"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaScanQueue">Injected queue used for processing media libraries scan jobs.</param>
|
||||
/// <param name="mediaLibrariesScanCancellationTracker">Injected service for scanning media libraries.</param>
|
||||
/// <param name="mediaLibrariesScanCancellationTracker">Injected tracker used for canceling media library scans.</param>
|
||||
public MediaLibraryScanJobProcessorJob(IMediaLibrariesScanQueue mediaScanQueue, IMediaLibrariesScanCancellationTracker mediaLibrariesScanCancellationTracker)
|
||||
{
|
||||
_mediaScanQueue = mediaScanQueue;
|
||||
@@ -43,7 +44,7 @@ internal sealed class MediaLibraryScanJobProcessorJob : BackgroundService
|
||||
await foreach (IMediaLibraryScanJob mediaScanJob in _mediaScanQueue.Reader.ReadAllAsync(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
// get the cancellation token that was associated with this library scan
|
||||
CancellationToken scanToken = _mediaLibrariesScanCancellationTracker.GetTokenForScan(mediaScanJob.ScanId.Value, mediaScanJob.UserId.Value);
|
||||
CancellationToken scanToken = _mediaLibrariesScanCancellationTracker.GetTokenForScan(MediaLibraryScanCompositeId.Create(mediaScanJob.ScanId, mediaScanJob.UserId));
|
||||
// create linked token to handle both scan cancellation and service shutdown
|
||||
CancellationTokenSource linkedSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, scanToken);
|
||||
mediaScanJob.ExecuteAsync(Guid.NewGuid(), new { }, linkedSource.Token).FireAndForgetSafeAsync(() => linkedSource.Dispose());
|
||||
@@ -50,12 +50,16 @@ public class EventualConsistencyMiddleware
|
||||
// only proceed if the response status code indicates success
|
||||
if (context.Response.StatusCode >= 200 && context.Response.StatusCode < 300)
|
||||
{
|
||||
// commit the transaction: because some domain events trigger jobs that end up being processed in background hosted services, and those are
|
||||
// singletons that require their own DI scope to be created, any changes made on the DbContext in this HTTP scope would not be seen on the
|
||||
// DbContext created in the background service scope, because the transaction is not yet commited here; therefor, the transaction needs to be
|
||||
// commited first, before any domain events are fired
|
||||
// see docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0002.md for details:
|
||||
await transaction.CommitAsync().ConfigureAwait(false);
|
||||
|
||||
// check if domain events exist in the channel queue and publish them
|
||||
while (domainEventQueue.TryDequeue(out IDomainEvent? nextEvent))
|
||||
await publisher.Publish(nextEvent);
|
||||
|
||||
// commit the transaction
|
||||
await transaction.CommitAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (EventualConsistencyException ex)
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetLibraryScanProgress;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/scans/{scanId}/progress</c> route.
|
||||
/// </summary>
|
||||
public class GetLibraryScanProgressEndpoint : BaseEndpoint<GetLibraryScanProgressRequest, IResult>
|
||||
{
|
||||
private readonly ISender _sender;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryScanProgressEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="sender">Injected service for mediating commands and queries.</param>
|
||||
public GetLibraryScanProgressEndpoint(ISender sender)
|
||||
{
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.GET);
|
||||
Routes(ApiRoutes.Libraries.LIBRARY_SCAN_PROGRESS);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library and of the scan whose progress is requested.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetLibraryScanProgressRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgressResponse> result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetLibraryScanProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetLibraryScanProgressEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryScanProgressEndpointSummary : Summary<GetLibraryScanProgressEndpoint, GetLibraryScanProgressRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryScanProgressEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetLibraryScanProgressEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the progress of a media library scan.";
|
||||
Description = "Retrieves the progress of a media library scan, if the user making the request is an Admin, or the owner of the library.";
|
||||
|
||||
ExampleRequest = new GetLibraryScanProgressRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
ScanId: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose scan progress is requested. Required.");
|
||||
RequestParam(r => r.ScanId, "The Id of the media library scan whose progress is requested. Required.");
|
||||
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.TotalJobs, "The total number of jobs to be processed by the scan.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.CompletedJobs, "The number of jobs that have been processed.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.CurrentJobProgress, "The progress of the currently processing job.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.Status, "The status of the scan.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.OverallProgressPercentage, "The ratio between the number of processed jobs and the total number of jobs to process, as percentage.");
|
||||
|
||||
Response(200, "The progress of the media library scan is returned.", example: new MediaLibraryScanProgressResponse(
|
||||
TotalJobs: 10,
|
||||
CompletedJobs: 4,
|
||||
CurrentJobProgress: new MediaLibraryScanJobProgressResponse(
|
||||
TotalItems: 1536,
|
||||
CompletedItems: 768,
|
||||
CurrentOperation: "Comparing file hashes",
|
||||
ProgressPercentage: 50
|
||||
),
|
||||
Status: LibraryScanJobStatus.Running,
|
||||
OverallProgressPercentage: 40
|
||||
));
|
||||
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/progress"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/progress"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/progress"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/progress",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the requested media library has no scan started.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "LibraryScanNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/progress",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/progress",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"LibraryScanIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class ScanLibrariesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<ScanLibraryResponse>> result = await _sender.Send(new ScanLibrariesCommand(), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<IEnumerable<MediaLibraryScanResponse>> result = await _sender.Send(new ScanLibrariesCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class ScanLibrariesEndpointSummary : Summary<ScanLibrariesEndpoint, Empty
|
||||
Description = "Starts the scanning process of all media libraries of a user, or all libraries, if the user is an Admin.";
|
||||
|
||||
Response(200, "The media libraries scan was successfully started.",
|
||||
example: new ScanLibraryResponse[] {
|
||||
example: new MediaLibraryScanResponse[] {
|
||||
new (
|
||||
ScanId: Guid.NewGuid(),
|
||||
LibraryId: Guid.NewGuid()
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class ScanLibraryEndpoint : BaseEndpoint<ScanLibraryRequest, IResult>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(ScanLibraryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<ScanLibraryResponse> result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<MediaLibraryScanResponse> result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
Description = "Starts the scanning process of a media library of a user.";
|
||||
|
||||
Response(200, "The media library scan was successfully started.",
|
||||
example: new ScanLibraryResponse(
|
||||
example: new MediaLibraryScanResponse(
|
||||
ScanId: Guid.NewGuid(),
|
||||
LibraryId: Guid.NewGuid()
|
||||
));
|
||||
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>Aktuelle Scan-Operation darf nicht leer sein!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>Die Scan-ID der Bibliothek darf nicht leer sein!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Gesamtanzahl der Scan-Aufträge muss positiv sein!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Anzahl der abgeschlossenen Scan-Aufträge muss positiv sein!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Anzahl der abgeschlossenen Scan-Aufträge darf die Gesamtanzahl der Scan-Aufträge nicht überschreiten!</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>Scan job current operation cannot be empty!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>Library scan Id cannot be empty!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Total scan jobs count must be positive!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Completed scan jobs count must be positive!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Completed scan jobs count can't exceed total scan jobs count!</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>¡La operación actual del escaneo no puede estar vacía!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>¡El ID de escaneo de la biblioteca no puede estar vacío!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>¡El número total de trabajos de escaneo debe ser positivo!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>¡El número de trabajos de escaneo completados debe ser positivo!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>¡El número de trabajos de escaneo completados no puede exceder el número total de trabajos de escaneo!</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>L'opération actuelle du scan ne peut pas être vide !</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>L'ID de scan de la bibliothèque ne peut pas être vide!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Le nombre total de tâches de scan doit être positif !</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Le nombre de tâches de scan terminées doit être positif !</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Le nombre de tâches de scan terminées ne peut pas dépasser le nombre total de tâches de scan !</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>L'operazione corrente della scansione non può essere vuota!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>L'ID della scansione della libreria non può essere vuoto!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Il numero totale dei lavori di scansione deve essere positivo!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Il numero dei lavori di scansione completati deve essere positivo!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Il numero dei lavori di scansione completati non può superare il numero totale dei lavori di scansione!</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>スキャンの現在の操作を空にすることはできません!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>ライブラリスキャンIDを空にすることはできません!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>スキャンジョブの合計数は正の値でなければなりません!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>完了したスキャンジョブ数は正の値でなければなりません!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>完了したスキャンジョブ数は合計スキャンジョブ数を超えることはできません!</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>Scan job current operation cannot be empty!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>Library scan Id cannot be empty!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Total scan jobs count must be positive!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Completed scan jobs count must be positive!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Completed scan jobs count can't exceed total scan jobs count!</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>Operația curentă de scanare nu poate fi goală!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>ID-ul de scanare al bibliotecii nu poate fi gol!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Numărul total de job-uri de scanare trebuie să fie pozitiv!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Numărul de job-uri de scanare completate trebuie să fie pozitiv!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Numărul de job-uri de scanare completate nu poate depăși numărul total de job-uri de scanare!</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>Текущая операция сканирования не может быть пустой!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>Идентификатор сканирования библиотеки не может быть пустым!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Общее количество заданий сканирования должно быть положительным!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>Количество завершенных заданий сканирования должно быть положительным!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Количество завершенных заданий сканирования не может превышать общее количество заданий сканирования!</value>
|
||||
</data>
|
||||
</root>
|
||||
+12
@@ -573,4 +573,16 @@
|
||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||
<value>扫描任务当前操作不能为空!</value>
|
||||
</data>
|
||||
<data name="LibraryScanIdCannotBeEmpty" xml:space="preserve">
|
||||
<value>库扫描ID不能为空!</value>
|
||||
</data>
|
||||
<data name="TotalScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>扫描任务总数必须为正数!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountMustBePositive" xml:space="preserve">
|
||||
<value>已完成扫描任务数量必须为正数!</value>
|
||||
</data>
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>已完成扫描任务数量不能超过扫描任务总数!</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>Comic-Serie</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Datei-Hashes werden verglichen...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Konzert</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>Filmreihe</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>Metadaten werden von GoodReads heruntergeladen...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>Grafischer Roman</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>Entfernen</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>Vergangene Scan-Daten werden abgerufen...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>Scandaten werden gespeichert...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>Scannen</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>Comic Series</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Comparing file hashes...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concert</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>Film Series</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>Downloading metadata from GoodReads...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>Graphic Novel</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>Remove</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>Retrieving past scan data...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>Saving scan data...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>Scan</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>Serie de Cómics</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Se están comparando hashes de archivos...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concierto</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>Saga Cinematográfica</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>Descargando metadatos de GoodReads...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>Novela Gráfica</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>Eliminar</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>Recuperando datos de escaneos anteriores...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>Guardando datos del escaneo...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>Escanear</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>Série de Bandes Dessinées</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Comparer les hachages de fichiers...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concert</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>Saga Cinématographique</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>Téléchargement des métadonnées depuis GoodReads...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>Roman Graphique</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>Supprimer</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>Récupération des données de scan précédentes...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>Sauvegarde des données de scan en cours...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>Scanner</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>Serie di Fumetti</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Si stanno confrontando gli hash dei file...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concerto</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>Saga Cinematografica</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>Scaricamento dei metadati da GoodReads...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>Romanzo Grafico</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>Rimuovere</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>Recupero dei dati di scansione precedenti...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>Salvataggio dei dati di scansione...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>Scansiona</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>漫画シリーズ</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>ファイルのハッシュを比較中...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>コンサート</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>映画シリーズ</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>GoodReadsからメタデータをダウンロード中...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>グラフィックノベル</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>削除</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>過去のスキャンデータを取得中...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>スキャンデータを保存中...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>スキャン</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>Comic Series</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Comparing file hashes...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concert</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>Film Series</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>Downloading metadata from GoodReads...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>Graphic Novel</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>Remove</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>Retrieving past scan data...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>Saving scan data...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>Scan</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>Serie de Benzi Desenate</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Se compară hash-urile fișierelor...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concert</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>Serie de Filme</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>Se descarcă metadate de pe GoodReads...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>Roman Grafic</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>Șterge</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>Se preiau datele de scanare anterioare...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>Se salvează datele de scanare...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>Scanează</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>Серия Комиксов</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Сравнение хешей файлов...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Концерт</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>Киносерия</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>Загрузка метаданных из GoodReads...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>Графический Роман</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>Удалить</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>Получение данных прошлых сканирований...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>Сохранение данных сканирования...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>Сканировать</value>
|
||||
</data>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<data name="ComicSeries" xml:space="preserve">
|
||||
<value>漫画系列</value>
|
||||
</data>
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>正在比较文件哈希值...</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>音乐会</value>
|
||||
</data>
|
||||
@@ -174,6 +177,9 @@
|
||||
<data name="FilmSeries" xml:space="preserve">
|
||||
<value>电影系列</value>
|
||||
</data>
|
||||
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||
<value>正在从GoodReads下载元数据...</value>
|
||||
</data>
|
||||
<data name="GraphicNovel" xml:space="preserve">
|
||||
<value>图像小说</value>
|
||||
</data>
|
||||
@@ -234,6 +240,12 @@
|
||||
<data name="Remove" xml:space="preserve">
|
||||
<value>删除</value>
|
||||
</data>
|
||||
<data name="RetrievingPastScanData" xml:space="preserve">
|
||||
<value>正在检索过去的扫描数据...</value>
|
||||
</data>
|
||||
<data name="SavingScanData" xml:space="preserve">
|
||||
<value>正在保存扫描数据...</value>
|
||||
</data>
|
||||
<data name="Scan" xml:space="preserve">
|
||||
<value>扫描</value>
|
||||
</data>
|
||||
|
||||
+8
-1
@@ -173,9 +173,15 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "architecture", "architecture", "{D93CA337-37D5-4A42-86B5-0A2410594A7A}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\docs\technical\architecture\1 system-context-diagram.puml = ..\docs\technical\architecture\1 system-context-diagram.puml
|
||||
..\docs\technical\architecture\1 system-context-diagram.svg = ..\docs\technical\architecture\1 system-context-diagram.svg
|
||||
..\docs\technical\architecture\2 container-diagram.puml = ..\docs\technical\architecture\2 container-diagram.puml
|
||||
..\docs\technical\architecture\2 container-diagram.svg = ..\docs\technical\architecture\2 container-diagram.svg
|
||||
..\docs\technical\architecture\3.1 component-web-client-diagram.puml = ..\docs\technical\architecture\3.1 component-web-client-diagram.puml
|
||||
..\docs\technical\architecture\3.2 component-server-diagram.puml = ..\docs\technical\architecture\3.2 component-server-diagram.puml
|
||||
..\docs\technical\architecture\3.1 component-web-client-diagram.svg = ..\docs\technical\architecture\3.1 component-web-client-diagram.svg
|
||||
..\docs\technical\architecture\3.2 component-api-server-diagram.puml = ..\docs\technical\architecture\3.2 component-api-server-diagram.puml
|
||||
..\docs\technical\architecture\3.2 component-api-server-diagram.svg = ..\docs\technical\architecture\3.2 component-api-server-diagram.svg
|
||||
..\docs\technical\architecture\4.1 code-media-library-scanning-diagram.puml = ..\docs\technical\architecture\4.1 code-media-library-scanning-diagram.puml
|
||||
..\docs\technical\architecture\4.1 code-media-library-scanning-diagram.svg = ..\docs\technical\architecture\4.1 code-media-library-scanning-diagram.svg
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "architecture-knowledge-management", "architecture-knowledge-management", "{70B56088-6D3A-481E-9459-79AC6B16FEC1}"
|
||||
@@ -183,6 +189,7 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "architecture-decision-log", "architecture-decision-log", "{788FADE4-342D-4919-8E5C-10CA8EDBE954}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decission-record-0001.md = ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decission-record-0001.md
|
||||
..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decission-record-0002.md = ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decission-record-0002.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
|
||||
Reference in new issue
Block a user