mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Moves media library scanning to domain layer
This commit is contained in:
1 parent
8b51abe0b2
commit
c4246d2e69
209 files changed
+3793
-641
No files matched your search
@@ -3,6 +3,10 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners.Common;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Scanners;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO.Abstractions;
|
||||
@@ -41,6 +45,10 @@ public static class DomainLayerServices
|
||||
services.AddScoped<IWindowsPathStrategy, WindowsPathStrategy>();
|
||||
services.AddScoped<IOperatingSystemInfo, OperatingSystemInfo>();
|
||||
services.AddScoped<IFileSystemStructureSeedService, FileSystemStructureSeedService>();
|
||||
services.AddScoped<IMediaLibraryScanJobFactory, MediaLibraryScanJobFactory>();
|
||||
services.AddScoped<IMediaLibraryScanningService, MediaLibraryScanningService>();
|
||||
services.AddScoped<IBookLibraryTypeScanner, BookLibraryTypeScanner>();
|
||||
services.AddScoped<IMediaLibraryScannerFactory, MediaLibraryScannerFactory>();
|
||||
services.AddSingleton<IFileSystem, FileSystem>();
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public enum LibraryScanJobStatus
|
||||
Completed,
|
||||
|
||||
/// <summary>
|
||||
/// Job has been cancelled.
|
||||
/// Job has been canceled.
|
||||
/// </summary>
|
||||
Cancelled,
|
||||
Canceled,
|
||||
|
||||
/// <summary>
|
||||
/// Job has failed.
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Errors;
|
||||
|
||||
/// <summary>
|
||||
/// Media Library Scan error types.
|
||||
/// </summary>
|
||||
public static partial class Errors
|
||||
{
|
||||
public static class LibraryScanning
|
||||
{
|
||||
public static Error CanOnlyStartPendingScans => Error.Forbidden(description: nameof(CanOnlyStartPendingScans));
|
||||
public static Error CanOnlyCancelRunningScans => Error.Forbidden(description: nameof(CanOnlyCancelRunningScans));
|
||||
public static Error CanOnlyFailRunningScans => Error.Forbidden(description: nameof(CanOnlyFailRunningScans));
|
||||
public static Error ScanIdCannotBeEmpty => Error.Validation(description: nameof(ScanIdCannotBeEmpty));
|
||||
public static Error LibraryScanAlreadyExists => Error.Conflict(description: nameof(LibraryScanAlreadyExists));
|
||||
public static Error LibraryAlreadyBeingScanned => Error.Forbidden(description: nameof(LibraryAlreadyBeingScanned));
|
||||
public static Error LibraryScanNotFound => Error.NotFound(description: nameof(LibraryScanNotFound));
|
||||
public static Error TotalScanJobItemsCountMustBePositive => Error.Validation(description: nameof(TotalScanJobItemsCountMustBePositive));
|
||||
public static Error CompletedScanJobItemsCountMustBePositive => Error.Validation(description: nameof(CompletedScanJobItemsCountMustBePositive));
|
||||
public static Error CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount => Error.Validation(description: nameof(CompletedScanJobItemsCountCantExceedTotalScanJobItemsCount));
|
||||
public static Error ScanJobCurrentOperationCannotBeEmpty => Error.Validation(description: nameof(ScanJobCurrentOperationCannotBeEmpty));
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,11 @@ public abstract class AggregateRoot<TId> : Entity<TId> where TId : notnull
|
||||
Id = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AggregateRoot{TId}"/> class.
|
||||
/// </summary>
|
||||
protected AggregateRoot() // only needed during reflection
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves and clears all domain events associated with this aggregate root.
|
||||
/// </summary>
|
||||
/// <returns>A list of all domain events that were raised by this aggregate root.</returns>
|
||||
public List<IDomainEvent> PopDomainEvents()
|
||||
public List<IDomainEvent> GetDomainEvents()
|
||||
{
|
||||
List<IDomainEvent> domainEventsCopy = [.. _domainEvents];
|
||||
_domainEvents.Clear();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
@@ -34,16 +34,6 @@ public abstract class Entity<TId> : IEquatable<Entity<TId>> where TId : notnull
|
||||
Id = id;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Entity{TId}"/> class.
|
||||
/// </summary>
|
||||
protected Entity() // only needed during reflection
|
||||
{
|
||||
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the current object is equal to another object of the same type.
|
||||
/// </summary>
|
||||
@@ -94,4 +84,4 @@ public abstract class Entity<TId> : IEquatable<Entity<TId>> where TId : notnull
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user