mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 08:11:10 +00:00
Adds media library scan progress tracking
This commit is contained in:
1 parent
e8dbf9456c
commit
27fa8e2e4f
87 files changed
+2073
-416
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 FluentValidation;
|
||||||
using Lumina.Application.Common.Behaviors;
|
using Lumina.Application.Common.Behaviors;
|
||||||
using Lumina.Application.Common.DomainEvents;
|
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 Mediator;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
@@ -44,15 +36,6 @@ public static class ApplicationLayerServices
|
|||||||
|
|
||||||
services.AddScoped<IDomainEventsQueue, DomainEventsQueue>();
|
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;
|
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>
|
/// </summary>
|
||||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||||
/// <returns>
|
/// <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>
|
/// </returns>
|
||||||
public static ErrorOr<LibraryScan> ToDomainEntity(this LibraryScanEntity repositoryEntity)
|
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>
|
/// <summary>
|
||||||
/// Command for initiating the scan of all media libraries.
|
/// Command for initiating the scan of all media libraries.
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Handler for the command for initiating the scan of all media libraries.
|
/// Handler for the command for initiating the scan of all media libraries.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScanLibrariesCommandHandler : IRequestHandler<ScanLibrariesCommand, ErrorOr<IEnumerable<ScanLibraryResponse>>>
|
public class ScanLibrariesCommandHandler : IRequestHandler<ScanLibrariesCommand, ErrorOr<IEnumerable<MediaLibraryScanResponse>>>
|
||||||
{
|
{
|
||||||
private readonly IUnitOfWork _unitOfWork;
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
private readonly ICurrentUserService _currentUserService;
|
private readonly ICurrentUserService _currentUserService;
|
||||||
@@ -57,7 +57,7 @@ public class ScanLibrariesCommandHandler : IRequestHandler<ScanLibrariesCommand,
|
|||||||
/// <param name="request">The request to be handled.</param>
|
/// <param name="request">The request to be handled.</param>
|
||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</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>
|
/// <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>();
|
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
|
||||||
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
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))
|
if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
|
||||||
domainEntitiesResult = domainEntitiesResult.Where(libraryResult => libraryResult.Value.UserId.Value == _currentUserService.UserId!.Value);
|
domainEntitiesResult = domainEntitiesResult.Where(libraryResult => libraryResult.Value.UserId.Value == _currentUserService.UserId!.Value);
|
||||||
|
|
||||||
List<ScanLibraryResponse> responses = [];
|
List<MediaLibraryScanResponse> responses = [];
|
||||||
List<IDomainEvent> domainEvents = [];
|
List<IDomainEvent> domainEvents = [];
|
||||||
|
|
||||||
// for each library, start the scan
|
// 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
|
// collect all the domain events created during this library scan start
|
||||||
domainEvents.AddRange(libraryScanResult.Value.GetDomainEvents());
|
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);
|
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>
|
/// <param name="Id">The unique identifier of the library to scan.</param>
|
||||||
public record ScanLibraryCommand(
|
public record ScanLibraryCommand(
|
||||||
Guid Id
|
Guid Id
|
||||||
) : IRequest<ErrorOr<ScanLibraryResponse>>;
|
) : IRequest<ErrorOr<MediaLibraryScanResponse>>;
|
||||||
+3
-3
@@ -28,7 +28,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibrary;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the command for initiating the scan of a media library.
|
/// Handler for the command for initiating the scan of a media library.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScanLibraryCommandHandler : IRequestHandler<ScanLibraryCommand, ErrorOr<ScanLibraryResponse>>
|
public class ScanLibraryCommandHandler : IRequestHandler<ScanLibraryCommand, ErrorOr<MediaLibraryScanResponse>>
|
||||||
{
|
{
|
||||||
private readonly IUnitOfWork _unitOfWork;
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
private readonly ICurrentUserService _currentUserService;
|
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="request">The request to be handled.</param>
|
||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</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>
|
/// <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>();
|
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
|
||||||
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
||||||
@@ -125,6 +125,6 @@ public class ScanLibraryCommandHandler : IRequestHandler<ScanLibraryCommand, Err
|
|||||||
foreach (IDomainEvent domainEvent in libraryScanResult.Value.GetDomainEvents())
|
foreach (IDomainEvent domainEvent in libraryScanResult.Value.GetDomainEvents())
|
||||||
_domainEventsQueue.Enqueue(domainEvent);
|
_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
|
// mark the media library scan as failed
|
||||||
ErrorOr<Success> failScanResult = libraryScanDomainResult.Value.FailScan();
|
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
|
// trying to set as failed a scan that has already been marked as failed by a concurrent job
|
||||||
if (!failScanResult.IsError)
|
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 =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
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 Mediator;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -12,6 +14,17 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Events;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class LibraryScanProgressChangedDomainEventHandler : INotificationHandler<LibraryScanProgressChangedDomainEvent>
|
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>
|
/// <summary>
|
||||||
/// Handles the event raised when a media library's scan progress changes.
|
/// Handles the event raised when a media library's scan progress changes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -19,6 +32,7 @@ public class LibraryScanProgressChangedDomainEventHandler : INotificationHandler
|
|||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
public async ValueTask Handle(LibraryScanProgressChangedDomainEvent domainEvent, CancellationToken cancellationToken)
|
public async ValueTask Handle(LibraryScanProgressChangedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
_mediaLibrariesScanProgressTracker.UpdateScanProgress(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId));
|
||||||
await Task.CompletedTask;
|
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 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 ||
|
if (getLibraryResult.Value.UserId != _currentUserService.UserId ||
|
||||||
(!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false) &&
|
!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
|
||||||
!await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.CanCreateLibraries, cancellationToken)))
|
|
||||||
return ApplicationErrors.Authorization.NotAuthorized;
|
return ApplicationErrors.Authorization.NotAuthorized;
|
||||||
|
|
||||||
return getLibraryResult.Value.ToResponse();
|
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="ScanId">The unique identifier of the media library scan.</param>
|
||||||
/// <param name="LibraryId">The unique identifier of the scanned media library.</param>
|
/// <param name="LibraryId">The unique identifier of the scanned media library.</param>
|
||||||
[DebuggerDisplay("ScanId: {ScanId} LibraryId: {LibraryId}")]
|
[DebuggerDisplay("ScanId: {ScanId} LibraryId: {LibraryId}")]
|
||||||
public record ScanLibraryResponse(
|
public record MediaLibraryScanResponse(
|
||||||
Guid ScanId,
|
Guid ScanId,
|
||||||
Guid LibraryId
|
Guid LibraryId
|
||||||
);
|
);
|
||||||
@@ -106,6 +106,6 @@ public sealed class UpdateAuditableEntitiesInterceptor : SaveChangesInterceptor
|
|||||||
|
|
||||||
// set modification properties
|
// set modification properties
|
||||||
entry.Entity.UpdatedOnUtc = utcNow;
|
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.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services;
|
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.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 Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Scanners;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
@@ -49,7 +50,9 @@ public static class DomainLayerServices
|
|||||||
services.AddScoped<IMediaLibraryScanningService, MediaLibraryScanningService>();
|
services.AddScoped<IMediaLibraryScanningService, MediaLibraryScanningService>();
|
||||||
services.AddScoped<IBookLibraryTypeScanner, BookLibraryTypeScanner>();
|
services.AddScoped<IBookLibraryTypeScanner, BookLibraryTypeScanner>();
|
||||||
services.AddScoped<IMediaLibraryScannerFactory, MediaLibraryScannerFactory>();
|
services.AddScoped<IMediaLibraryScannerFactory, MediaLibraryScannerFactory>();
|
||||||
|
|
||||||
services.AddSingleton<IFileSystem, FileSystem>();
|
services.AddSingleton<IFileSystem, FileSystem>();
|
||||||
|
services.AddSingleton<IMediaLibrariesScanProgressTracker, MediaLibrariesScanProgressTracker>();
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,9 @@ public static partial class Errors
|
|||||||
{
|
{
|
||||||
public static class LibraryScanning
|
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 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 CanOnlyCancelRunningScans => Error.Forbidden(description: nameof(CanOnlyCancelRunningScans));
|
||||||
public static Error CanOnlyFailRunningScans => Error.Forbidden(description: nameof(CanOnlyFailRunningScans));
|
public static Error CanOnlyFailRunningScans => Error.Forbidden(description: nameof(CanOnlyFailRunningScans));
|
||||||
public static Error ScanIdCannotBeEmpty => Error.Validation(description: nameof(ScanIdCannotBeEmpty));
|
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 LibraryAlreadyBeingScanned => Error.Forbidden(description: nameof(LibraryAlreadyBeingScanned));
|
||||||
public static Error LibraryScanNotFound => Error.NotFound(description: nameof(LibraryScanNotFound));
|
public static Error LibraryScanNotFound => Error.NotFound(description: nameof(LibraryScanNotFound));
|
||||||
public static Error TotalScanJobItemsCountMustBePositive => Error.Validation(description: nameof(TotalScanJobItemsCountMustBePositive));
|
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 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 CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount => Error.Validation(description: nameof(CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount));
|
||||||
|
public static Error CompletedScanJobsCountCantExceedTotalScanJobsCount => Error.Validation(description: nameof(CompletedScanJobsCountCantExceedTotalScanJobsCount));
|
||||||
public static Error ScanJobCurrentOperationCannotBeEmpty => Error.Validation(description: nameof(ScanJobCurrentOperationCannotBeEmpty));
|
public static Error ScanJobCurrentOperationCannotBeEmpty => Error.Validation(description: nameof(ScanJobCurrentOperationCannotBeEmpty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-5
@@ -1,6 +1,8 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Domain.Common.Events;
|
using Lumina.Domain.Common.Events;
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
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;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -8,14 +10,16 @@ using System.Diagnostics;
|
|||||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Domain event raised when a libary scan is completed.
|
/// Domain event raised when a libary scan is finished.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
/// <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>
|
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||||
[DebuggerDisplay("Id: {Id}")]
|
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||||
public record LibraryScanCompletedDomainEvent(
|
public record LibraryScanFinishedDomainEvent(
|
||||||
Guid Id,
|
Guid Id,
|
||||||
LibraryId LibraryId,
|
ScanId ScanId,
|
||||||
|
UserId UserId,
|
||||||
DateTime OccurredOnUtc
|
DateTime OccurredOnUtc
|
||||||
) : IDomainEvent;
|
) : 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.Common.Events;
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||||
|
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -12,13 +13,13 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
|||||||
/// Domain event raised when a libary's scan progress changes.
|
/// Domain event raised when a libary's scan progress changes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
/// <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="ScanId">The object representing the unique identifier of the media library scan.</param>
|
||||||
/// <param name="LibraryId">The unique identifier of the library whose scan progress changes.</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>
|
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||||
[DebuggerDisplay("Id: {Id}")]
|
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||||
public record LibraryScanProgressChangedDomainEvent(
|
public record LibraryScanProgressChangedDomainEvent(
|
||||||
Guid Id,
|
Guid Id,
|
||||||
ScanId ScanId,
|
ScanId ScanId,
|
||||||
LibraryId LibraryId,
|
UserId UserId,
|
||||||
DateTime OccurredOnUtc
|
DateTime OccurredOnUtc
|
||||||
) : IDomainEvent;
|
) : IDomainEvent;
|
||||||
+14
@@ -119,6 +119,20 @@ public class LibraryScan : AggregateRoot<ScanId>
|
|||||||
return Result.Success;
|
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>
|
/// <summary>
|
||||||
/// Cancels the media library scan.
|
/// Cancels the media library scan.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+12
-15
@@ -1,5 +1,5 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System;
|
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -11,30 +11,27 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
|||||||
public interface IMediaLibrariesScanCancellationTracker
|
public interface IMediaLibrariesScanCancellationTracker
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="scanId">The unique identifier of the scan to get the cancellation token for.</param>
|
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</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>
|
/// <returns>A cancellation token for the specified scan.</returns>
|
||||||
CancellationToken GetTokenForScan(Guid scanId, Guid userId);
|
CancellationToken GetTokenForScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a new scan operation for tracking.
|
/// Registers a new scan operation for tracking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scanId">The unique identifier of the scan operation to track.</param>
|
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||||
/// <param name="userId">The unique identifier of the user who initiated the scan to track.</param>
|
void RegisterScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||||
void RegisterScan(Guid scanId, Guid userId);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancels a scan identified by <paramref name="scanId"/> and <paramref name="userId"/>.
|
/// Removes a scan operation from tracking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scanId">The unique identifier of the scan operation to cancel.</param>
|
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||||
/// <param name="userId">The unique identifier of the user requesting the cancellation.</param>
|
void RemoveScan(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||||
void CancelScan(Guid scanId, Guid userId);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancels all active scan operations for a user identified by <paramref name="userId"/>.
|
/// Cancels a scan identified by <paramref name="mediaLibraryScanCompositeId"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">The unique identifier of the user whose scans should be canceled.</param>
|
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||||
void CancelUserScans(Guid userId);
|
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
|
public abstract class MediaLibraryScanJob : IMediaLibraryScanJob
|
||||||
{
|
{
|
||||||
protected int parentsPayloadsExecuted;
|
protected int parentsPayloadsExecuted;
|
||||||
protected ScanJobProgress? _jobProgress;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the Id of the media library scan that this job is part of.
|
/// Gets or sets the Id of the media library scan that this job is part of.
|
||||||
|
|||||||
+79
-17
@@ -1,11 +1,15 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using ErrorOr;
|
using ErrorOr;
|
||||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
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.Cancellation;
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
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.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.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||||
|
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||||
|
using Mediator;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -20,23 +24,32 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||||
{
|
{
|
||||||
private readonly IMediaLibrariesScanQueue _mediaScanQueue;
|
private readonly IMediaLibrariesScanQueue _mediaLibrariesScanQueue;
|
||||||
private readonly IMediaLibraryScannerFactory _libraryScannerFactory;
|
private readonly IMediaLibraryScannerFactory _mediaLibraryScannerFactory;
|
||||||
private readonly IMediaLibrariesScanCancellationTracker _mediaLibrariesScanCancellationTracker;
|
private readonly IMediaLibrariesScanCancellationTracker _mediaLibrariesScanCancellationTracker;
|
||||||
|
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||||
|
private readonly IPublisher _publisher;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="MediaLibraryScanningService"/> class.
|
/// Initializes a new instance of the <see cref="MediaLibraryScanningService"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mediaScanQueue">Injected queue used for processing media libraries scan jobs.</param>
|
/// <param name="mediaLibrariesScanQueue">Injected queue used for processing media libraries scan jobs.</param>
|
||||||
/// <param name="libraryScannerFactory">Injected factory for creating media library scanners.</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(
|
public MediaLibraryScanningService(
|
||||||
IMediaLibrariesScanQueue mediaScanQueue,
|
IMediaLibrariesScanQueue mediaLibrariesScanQueue,
|
||||||
IMediaLibraryScannerFactory libraryScannerFactory,
|
IMediaLibraryScannerFactory mediaLibraryScannerFactory,
|
||||||
IMediaLibrariesScanCancellationTracker mediaLibrariesScanCancellationTracker)
|
IMediaLibrariesScanCancellationTracker mediaLibrariesScanCancellationTracker,
|
||||||
|
IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker,
|
||||||
|
IPublisher publisher)
|
||||||
{
|
{
|
||||||
_mediaScanQueue = mediaScanQueue;
|
_mediaLibrariesScanQueue = mediaLibrariesScanQueue;
|
||||||
_libraryScannerFactory = libraryScannerFactory;
|
_mediaLibraryScannerFactory = mediaLibraryScannerFactory;
|
||||||
_mediaLibrariesScanCancellationTracker = mediaLibrariesScanCancellationTracker;
|
_mediaLibrariesScanCancellationTracker = mediaLibrariesScanCancellationTracker;
|
||||||
|
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||||
|
_publisher = publisher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -53,25 +66,34 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
|||||||
ErrorOr<Success> startScanResult = scan.StartScan();
|
ErrorOr<Success> startScanResult = scan.StartScan();
|
||||||
if (startScanResult.IsError)
|
if (startScanResult.IsError)
|
||||||
return startScanResult.Errors;
|
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
|
// 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
|
try
|
||||||
{
|
{
|
||||||
// link the user's cancellation token with the scan's token
|
// link the user's cancellation token with the scan's token
|
||||||
CancellationTokenSource linkedSource = CancellationTokenSource
|
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
|
// 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
|
// get the list of scan jobs for the retrieved scanner
|
||||||
List<IMediaLibraryScanJob> jobs = scanner.CreateScanJobsForLibrary(scan.LibraryId, downloadMedatadaFromWeb).ToList();
|
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
|
// enqueue the jobs on the channel from where they will be processed
|
||||||
foreach (IMediaLibraryScanJob job in jobs)
|
foreach (IMediaLibraryScanJob job in jobs)
|
||||||
{
|
{
|
||||||
job.ScanId = scan.Id;
|
// set the Id of the scan and of the user initiating the scan to all jobs in the scan job graph
|
||||||
job.UserId = scan.UserId;
|
SetScanPropertiesForJobChain(job, scan.Id, scan.UserId);
|
||||||
await _mediaScanQueue.Writer.WriteAsync(job, linkedSource.Token).ConfigureAwait(false);
|
await _mediaLibrariesScanQueue.Writer.WriteAsync(job, linkedSource.Token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NotImplementedException) { }
|
catch (NotImplementedException) { }
|
||||||
@@ -86,7 +108,47 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
|||||||
public ErrorOr<Success> CancelScan(LibraryScan scan)
|
public ErrorOr<Success> CancelScan(LibraryScan scan)
|
||||||
{
|
{
|
||||||
// trigger the process that cancels the jobs of the 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;
|
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;
|
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface defining a factory for creating media library scanners.
|
/// 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;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface defining a media library scanner for a specific media library type.
|
/// Interface defining a media library scanner for a specific media library type.
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using System;
|
using System;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a factory for creating media library scanners.
|
/// 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.
|
/// Value Object representing a progress snapshot of a media library scan job.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("CompletedItems: {CompletedItems}; TotalItems: {TotalItems}; CurrentOperation: {CurrentOperation}")]
|
[DebuggerDisplay("CompletedItems: {CompletedItems}; TotalItems: {TotalItems}; CurrentOperation: {CurrentOperation}")]
|
||||||
public sealed class ScanJobProgress : ValueObject
|
public sealed class MediaLibraryScanJobProgress : ValueObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the number of completed items of the media library scan job.
|
/// Gets the number of completed items of the media library scan job.
|
||||||
@@ -32,15 +32,15 @@ public sealed class ScanJobProgress : ValueObject
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the ratio between the total number and the completed number of items, as a percentage.
|
/// Gets the ratio between the total number and the completed number of items, as a percentage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal ProgressPercentage => CompletedItems * 100.0m / TotalItems;
|
public decimal ProgressPercentage => TotalItems > 0 ? CompletedItems * 100.0m / TotalItems : 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ScanJobProgress"/> class.
|
/// Initializes a new instance of the <see cref="MediaLibraryScanJobProgress"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="completedItems">The number of completed items of the media library scan job.</param>
|
/// <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="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>
|
/// <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;
|
CompletedItems = completedItems;
|
||||||
TotalItems = totalItems;
|
TotalItems = totalItems;
|
||||||
@@ -48,17 +48,17 @@ public sealed class ScanJobProgress : ValueObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="ScanJobProgress"/> class.
|
/// Creates a new instance of the <see cref="MediaLibraryScanJobProgress"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="completedItems">The number of completed items of the media library scan job.</param>
|
/// <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="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>
|
/// <param name="currentOperation">The current operation being performed by the media library scan job.</param>
|
||||||
/// <returns>
|
/// <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>
|
/// </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;
|
return Errors.LibraryScanning.TotalScanJobItemsCountMustBePositive;
|
||||||
if (completedItems < 0)
|
if (completedItems < 0)
|
||||||
return Errors.LibraryScanning.CompletedScanJobItemsCountMustBePositive;
|
return Errors.LibraryScanning.CompletedScanJobItemsCountMustBePositive;
|
||||||
@@ -66,7 +66,7 @@ public sealed class ScanJobProgress : ValueObject
|
|||||||
return Errors.LibraryScanning.CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount;
|
return Errors.LibraryScanning.CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount;
|
||||||
if (string.IsNullOrWhiteSpace(currentOperation))
|
if (string.IsNullOrWhiteSpace(currentOperation))
|
||||||
return Errors.LibraryScanning.ScanJobCurrentOperationCannotBeEmpty;
|
return Errors.LibraryScanning.ScanJobCurrentOperationCannotBeEmpty;
|
||||||
return new ScanJobProgress(completedItems, totalItems, currentOperation);
|
return new MediaLibraryScanJobProgress(completedItems, totalItems, currentOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <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);
|
IRepositoryMetadataDiscoveryJob repositoryMetadataDiscoveryJob = _mediaScanJobFactory.CreateJob<IRepositoryMetadataDiscoveryJob>(libraryId);
|
||||||
IHashComparerJob hashComparerJob = _mediaScanJobFactory.CreateJob<IHashComparerJob>(libraryId);
|
IHashComparerJob hashComparerJob = _mediaScanJobFactory.CreateJob<IHashComparerJob>(libraryId);
|
||||||
IGoodReadsMetadataScrapJob goodReadsMetadataScrapJob = _mediaScanJobFactory.CreateJob<IGoodReadsMetadataScrapJob>(libraryId);
|
IGoodReadsMetadataScrapJob goodReadsMetadataScrapJob = _mediaScanJobFactory.CreateJob<IGoodReadsMetadataScrapJob>(libraryId);
|
||||||
|
IRepositoryMetadataSaveJob repositoryMetadataSaveJob = _mediaScanJobFactory.CreateJob<IRepositoryMetadataSaveJob>(libraryId);
|
||||||
|
|
||||||
// establish the hierarchical relationships between jobs
|
// establish the hierarchical relationships between jobs
|
||||||
fileSystemDiscoveryJob.AddChild(hashComparerJob);
|
fileSystemDiscoveryJob.AddChild(hashComparerJob);
|
||||||
@@ -46,7 +47,16 @@ internal class BookLibraryTypeScanner : IBookLibraryTypeScanner
|
|||||||
if (downloadMedatadaFromWeb)
|
if (downloadMedatadaFromWeb)
|
||||||
{
|
{
|
||||||
hashComparerJob.AddChild(goodReadsMetadataScrapJob);
|
hashComparerJob.AddChild(goodReadsMetadataScrapJob);
|
||||||
|
goodReadsMetadataScrapJob.AddChild(repositoryMetadataSaveJob);
|
||||||
|
|
||||||
goodReadsMetadataScrapJob.AddParent(hashComparerJob);
|
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
|
// return the top level jobs that will be triggered when the scan will be started
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Scanners;
|
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Scanners;
|
||||||
|
|||||||
@@ -22,8 +22,4 @@
|
|||||||
<PackageReference Include="Mediator.Abstractions" Version="3.0.0-preview.27" />
|
<PackageReference Include="Mediator.Abstractions" Version="3.0.0-preview.27" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Core\BoundedContexts\LibraryManagementBoundedContext\LibraryScanAggregate\Services\Progress\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -5,10 +5,18 @@ using Lumina.Application.Common.Infrastructure.Authorization;
|
|||||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.Over18;
|
using Lumina.Application.Common.Infrastructure.Authorization.Policies.Over18;
|
||||||
using Lumina.Application.Common.Infrastructure.Security;
|
using Lumina.Application.Common.Infrastructure.Security;
|
||||||
using Lumina.Application.Common.Infrastructure.Time;
|
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.Authentication;
|
||||||
using Lumina.Infrastructure.Core.Authorization;
|
using Lumina.Infrastructure.Core.Authorization;
|
||||||
using Lumina.Infrastructure.Core.Authorization.Policies.Common.Factory;
|
using Lumina.Infrastructure.Core.Authorization.Policies.Common.Factory;
|
||||||
using Lumina.Infrastructure.Core.Authorization.Policies.Over18;
|
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.Security;
|
||||||
using Lumina.Infrastructure.Core.Time;
|
using Lumina.Infrastructure.Core.Time;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@@ -46,6 +54,17 @@ public static class InfrastructureLayerServices
|
|||||||
services.AddScoped<IOver18Policy, Over18Policy>();
|
services.AddScoped<IOver18Policy, Over18Policy>();
|
||||||
services.AddScoped<IAuthorizationPolicyFactory, AuthorizationPolicyFactory>();
|
services.AddScoped<IAuthorizationPolicyFactory, AuthorizationPolicyFactory>();
|
||||||
services.AddScoped<IAuthorizationService, AuthorizationService>();
|
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;
|
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.Entities.MediaLibrary.Management;
|
||||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||||
using Lumina.Application.Common.DataAccess.UoW;
|
using Lumina.Application.Common.DataAccess.UoW;
|
||||||
using Lumina.Application.Common.DomainEvents;
|
|
||||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
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.FileSystem;
|
||||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||||
using Lumina.Domain.Common.Primitives;
|
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.Events;
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||||
|
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Payloads;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
using System;
|
||||||
@@ -24,7 +23,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.Common;
|
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Media library scan job for discovering file system items.
|
/// 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
|
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
|
// 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)
|
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
|
||||||
Status = LibraryScanJobStatus.Running;
|
// file system processing that takes time, and would block the processing of scan jobs in the in-memory queue
|
||||||
|
await Task.Run(async () =>
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
Status = LibraryScanJobStatus.Running;
|
||||||
return;
|
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
|
// get the library from the repository
|
||||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||||
if (domainLibraryResult.IsError)
|
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
// handle errors, maybe:
|
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||||
// Status = LibraryScanJobStatus.Failed;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
contentLocationTrees.Add(treeResult.Value);
|
|
||||||
|
|
||||||
// increment the number of processed elements progress
|
// convert it to a domain object
|
||||||
scanJobProgressResult = ScanJobProgress.Create(
|
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "DiscoveringFiles");
|
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)
|
if (scanJobProgressResult.IsError)
|
||||||
{
|
{
|
||||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||||
Console.WriteLine("ended file discovering");
|
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||||
Status = LibraryScanJobStatus.Completed;
|
|
||||||
// call each linked child with the obtained payload
|
// recursively get the file system tree for each of the media library content locations
|
||||||
foreach (IMediaLibraryScanJob children in Children)
|
List<FileSystemTreeNode> contentLocationTrees = [];
|
||||||
await children.ExecuteAsync(id, contentLocationTrees, cancellationToken).ConfigureAwait(false);
|
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)
|
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;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Jobs.Payloads;
|
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Payloads;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic file system node.
|
/// 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>
|
/// </summary>
|
||||||
internal class MediaLibrariesScanQueue : IMediaLibrariesScanQueue
|
internal class MediaLibrariesScanQueue : IMediaLibrariesScanQueue
|
||||||
{
|
{
|
||||||
private readonly Channel<IMediaLibraryScanJob> _channel = Channel.CreateUnbounded<IMediaLibraryScanJob>(new UnboundedChannelOptions
|
private readonly Channel<IMediaLibraryScanJob> _channel = Channel.CreateUnbounded<IMediaLibraryScanJob>();
|
||||||
{
|
|
||||||
SingleWriter = false,
|
|
||||||
SingleReader = false,
|
|
||||||
AllowSynchronousContinuations = true
|
|
||||||
});
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the writer for the queue, allowing producers to enqueue <see cref="IMediaLibraryScanJob"/> instances.
|
/// 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.Cancellation;
|
||||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
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.Services.Queue;
|
||||||
|
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -23,7 +24,7 @@ internal sealed class MediaLibraryScanJobProcessorJob : BackgroundService
|
|||||||
/// Initializes a new instance of the <see cref="MediaLibraryScanJobProcessorJob"/> class.
|
/// Initializes a new instance of the <see cref="MediaLibraryScanJobProcessorJob"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mediaScanQueue">Injected queue used for processing media libraries scan jobs.</param>
|
/// <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)
|
public MediaLibraryScanJobProcessorJob(IMediaLibrariesScanQueue mediaScanQueue, IMediaLibrariesScanCancellationTracker mediaLibrariesScanCancellationTracker)
|
||||||
{
|
{
|
||||||
_mediaScanQueue = mediaScanQueue;
|
_mediaScanQueue = mediaScanQueue;
|
||||||
@@ -43,7 +44,7 @@ internal sealed class MediaLibraryScanJobProcessorJob : BackgroundService
|
|||||||
await foreach (IMediaLibraryScanJob mediaScanJob in _mediaScanQueue.Reader.ReadAllAsync(cancellationToken).ConfigureAwait(false))
|
await foreach (IMediaLibraryScanJob mediaScanJob in _mediaScanQueue.Reader.ReadAllAsync(cancellationToken).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
// get the cancellation token that was associated with this library scan
|
// 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
|
// create linked token to handle both scan cancellation and service shutdown
|
||||||
CancellationTokenSource linkedSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, scanToken);
|
CancellationTokenSource linkedSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, scanToken);
|
||||||
mediaScanJob.ExecuteAsync(Guid.NewGuid(), new { }, linkedSource.Token).FireAndForgetSafeAsync(() => linkedSource.Dispose());
|
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
|
// only proceed if the response status code indicates success
|
||||||
if (context.Response.StatusCode >= 200 && context.Response.StatusCode < 300)
|
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
|
// check if domain events exist in the channel queue and publish them
|
||||||
while (domainEventQueue.TryDequeue(out IDomainEvent? nextEvent))
|
while (domainEventQueue.TryDequeue(out IDomainEvent? nextEvent))
|
||||||
await publisher.Publish(nextEvent);
|
await publisher.Publish(nextEvent);
|
||||||
|
|
||||||
// commit the transaction
|
|
||||||
await transaction.CommitAsync().ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (EventualConsistencyException ex)
|
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>
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
|
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);
|
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.";
|
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.",
|
Response(200, "The media libraries scan was successfully started.",
|
||||||
example: new ScanLibraryResponse[] {
|
example: new MediaLibraryScanResponse[] {
|
||||||
new (
|
new (
|
||||||
ScanId: Guid.NewGuid(),
|
ScanId: Guid.NewGuid(),
|
||||||
LibraryId: 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>
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
public override async Task<IResult> ExecuteAsync(ScanLibraryRequest request, CancellationToken cancellationToken)
|
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);
|
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.";
|
Description = "Starts the scanning process of a media library of a user.";
|
||||||
|
|
||||||
Response(200, "The media library scan was successfully started.",
|
Response(200, "The media library scan was successfully started.",
|
||||||
example: new ScanLibraryResponse(
|
example: new MediaLibraryScanResponse(
|
||||||
ScanId: Guid.NewGuid(),
|
ScanId: Guid.NewGuid(),
|
||||||
LibraryId: Guid.NewGuid()
|
LibraryId: Guid.NewGuid()
|
||||||
));
|
));
|
||||||
|
|||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>Aktuelle Scan-Operation darf nicht leer sein!</value>
|
<value>Aktuelle Scan-Operation darf nicht leer sein!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>Scan job current operation cannot be empty!</value>
|
<value>Scan job current operation cannot be empty!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>¡La operación actual del escaneo no puede estar vacía!</value>
|
<value>¡La operación actual del escaneo no puede estar vacía!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>L'opération actuelle du scan ne peut pas être vide !</value>
|
<value>L'opération actuelle du scan ne peut pas être vide !</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>L'operazione corrente della scansione non può essere vuota!</value>
|
<value>L'operazione corrente della scansione non può essere vuota!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>スキャンの現在の操作を空にすることはできません!</value>
|
<value>スキャンの現在の操作を空にすることはできません!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>Scan job current operation cannot be empty!</value>
|
<value>Scan job current operation cannot be empty!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>Operația curentă de scanare nu poate fi goală!</value>
|
<value>Operația curentă de scanare nu poate fi goală!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>Текущая операция сканирования не может быть пустой!</value>
|
<value>Текущая операция сканирования не может быть пустой!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
+12
@@ -573,4 +573,16 @@
|
|||||||
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
<data name="ScanJobCurrentOperationCannotBeEmpty" xml:space="preserve">
|
||||||
<value>扫描任务当前操作不能为空!</value>
|
<value>扫描任务当前操作不能为空!</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>Comic-Serie</value>
|
<value>Comic-Serie</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>Datei-Hashes werden verglichen...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>Konzert</value>
|
<value>Konzert</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>Filmreihe</value>
|
<value>Filmreihe</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>Metadaten werden von GoodReads heruntergeladen...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>Grafischer Roman</value>
|
<value>Grafischer Roman</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>Entfernen</value>
|
<value>Entfernen</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>Scannen</value>
|
<value>Scannen</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>Comic Series</value>
|
<value>Comic Series</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>Comparing file hashes...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>Concert</value>
|
<value>Concert</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>Film Series</value>
|
<value>Film Series</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>Downloading metadata from GoodReads...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>Graphic Novel</value>
|
<value>Graphic Novel</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>Remove</value>
|
<value>Remove</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>Scan</value>
|
<value>Scan</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>Serie de Cómics</value>
|
<value>Serie de Cómics</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>Se están comparando hashes de archivos...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>Concierto</value>
|
<value>Concierto</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>Saga Cinematográfica</value>
|
<value>Saga Cinematográfica</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>Descargando metadatos de GoodReads...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>Novela Gráfica</value>
|
<value>Novela Gráfica</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>Eliminar</value>
|
<value>Eliminar</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>Escanear</value>
|
<value>Escanear</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>Série de Bandes Dessinées</value>
|
<value>Série de Bandes Dessinées</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>Comparer les hachages de fichiers...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>Concert</value>
|
<value>Concert</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>Saga Cinématographique</value>
|
<value>Saga Cinématographique</value>
|
||||||
</data>
|
</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">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>Roman Graphique</value>
|
<value>Roman Graphique</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>Supprimer</value>
|
<value>Supprimer</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>Scanner</value>
|
<value>Scanner</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>Serie di Fumetti</value>
|
<value>Serie di Fumetti</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>Si stanno confrontando gli hash dei file...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>Concerto</value>
|
<value>Concerto</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>Saga Cinematografica</value>
|
<value>Saga Cinematografica</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>Scaricamento dei metadati da GoodReads...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>Romanzo Grafico</value>
|
<value>Romanzo Grafico</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>Rimuovere</value>
|
<value>Rimuovere</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>Scansiona</value>
|
<value>Scansiona</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>漫画シリーズ</value>
|
<value>漫画シリーズ</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>ファイルのハッシュを比較中...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>コンサート</value>
|
<value>コンサート</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>映画シリーズ</value>
|
<value>映画シリーズ</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>GoodReadsからメタデータをダウンロード中...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>グラフィックノベル</value>
|
<value>グラフィックノベル</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>削除</value>
|
<value>削除</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>スキャン</value>
|
<value>スキャン</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>Comic Series</value>
|
<value>Comic Series</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>Comparing file hashes...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>Concert</value>
|
<value>Concert</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>Film Series</value>
|
<value>Film Series</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>Downloading metadata from GoodReads...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>Graphic Novel</value>
|
<value>Graphic Novel</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>Remove</value>
|
<value>Remove</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>Scan</value>
|
<value>Scan</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>Serie de Benzi Desenate</value>
|
<value>Serie de Benzi Desenate</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>Se compară hash-urile fișierelor...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>Concert</value>
|
<value>Concert</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>Serie de Filme</value>
|
<value>Serie de Filme</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>Se descarcă metadate de pe GoodReads...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>Roman Grafic</value>
|
<value>Roman Grafic</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>Șterge</value>
|
<value>Șterge</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>Scanează</value>
|
<value>Scanează</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>Серия Комиксов</value>
|
<value>Серия Комиксов</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>Сравнение хешей файлов...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>Концерт</value>
|
<value>Концерт</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>Киносерия</value>
|
<value>Киносерия</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>Загрузка метаданных из GoodReads...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>Графический Роман</value>
|
<value>Графический Роман</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>Удалить</value>
|
<value>Удалить</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>Сканировать</value>
|
<value>Сканировать</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -144,6 +144,9 @@
|
|||||||
<data name="ComicSeries" xml:space="preserve">
|
<data name="ComicSeries" xml:space="preserve">
|
||||||
<value>漫画系列</value>
|
<value>漫画系列</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ComparingFileHashes" xml:space="preserve">
|
||||||
|
<value>正在比较文件哈希值...</value>
|
||||||
|
</data>
|
||||||
<data name="Concert" xml:space="preserve">
|
<data name="Concert" xml:space="preserve">
|
||||||
<value>音乐会</value>
|
<value>音乐会</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -174,6 +177,9 @@
|
|||||||
<data name="FilmSeries" xml:space="preserve">
|
<data name="FilmSeries" xml:space="preserve">
|
||||||
<value>电影系列</value>
|
<value>电影系列</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GoodReadsMetadataDownload" xml:space="preserve">
|
||||||
|
<value>正在从GoodReads下载元数据...</value>
|
||||||
|
</data>
|
||||||
<data name="GraphicNovel" xml:space="preserve">
|
<data name="GraphicNovel" xml:space="preserve">
|
||||||
<value>图像小说</value>
|
<value>图像小说</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -234,6 +240,12 @@
|
|||||||
<data name="Remove" xml:space="preserve">
|
<data name="Remove" xml:space="preserve">
|
||||||
<value>删除</value>
|
<value>删除</value>
|
||||||
</data>
|
</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">
|
<data name="Scan" xml:space="preserve">
|
||||||
<value>扫描</value>
|
<value>扫描</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
+8
-1
@@ -173,9 +173,15 @@ EndProject
|
|||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "architecture", "architecture", "{D93CA337-37D5-4A42-86B5-0A2410594A7A}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "architecture", "architecture", "{D93CA337-37D5-4A42-86B5-0A2410594A7A}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
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.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.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.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
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "architecture-knowledge-management", "architecture-knowledge-management", "{70B56088-6D3A-481E-9459-79AC6B16FEC1}"
|
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}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "architecture-decision-log", "architecture-decision-log", "{788FADE4-342D-4919-8E5C-10CA8EDBE954}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
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-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
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|||||||
Reference in new issue
Block a user