Moves media library scanning to domain layer

This commit is contained in:
BinaryAlley committed 2025-02-16 21:45:26 +02:00
1 parent 8b51abe0b2
commit c4246d2e69
209 files changed
+3793 -641

No files matched your search

@@ -4,6 +4,8 @@ using ErrorOr;
using Lumina.Domain.Common.Enums.MediaLibrary;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
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.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -44,7 +46,7 @@ public class DomainLibraryFixture
];
ErrorOr<Library> library = Library.Create(
Guid.NewGuid(),
UserId.CreateUnique(),
_faker.Random.String2(_faker.Random.Number(1, 50)),
_faker.PickRandom<LibraryType>(),
validPaths.Take(_random.Next(1, validPaths.Count)),
@@ -52,7 +54,8 @@ public class DomainLibraryFixture
_faker.Random.Bool(),
_faker.Random.Bool(),
_faker.Random.Bool(),
_faker.Random.Bool()
_faker.Random.Bool(),
[ScanId.CreateUnique(), ScanId.CreateUnique()]
);
return library.Value;
@@ -68,11 +71,12 @@ public class DomainLibraryFixture
bool isEnabled = true,
bool isLocked = false,
bool downloadMedatadaFromWeb = true,
bool saveMetadataInMediaDirectories = false)
bool saveMetadataInMediaDirectories = false,
IEnumerable<Guid>? scanIds = null)
{
ErrorOr<Library> library = id is null ?
Library.Create(
userId ?? Guid.NewGuid(),
userId is not null ? UserId.Create(userId.Value) : UserId.CreateUnique(),
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
libraryType ?? LibraryType.Book,
contentLocations ?? ["C:/Media"],
@@ -80,11 +84,12 @@ public class DomainLibraryFixture
isEnabled,
isLocked,
downloadMedatadaFromWeb,
saveMetadataInMediaDirectories
saveMetadataInMediaDirectories,
scanIds?.Select(scanId => ScanId.Create(scanId)).ToList() ?? [ScanId.CreateUnique(), ScanId.CreateUnique()]
) :
Library.Create(
LibraryId.Create(id.Value),
userId ?? Guid.NewGuid(),
userId is not null ? UserId.Create(userId.Value) : UserId.CreateUnique(),
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
libraryType ?? LibraryType.Book,
contentLocations ?? ["C:/Media"],
@@ -92,7 +97,8 @@ public class DomainLibraryFixture
isEnabled,
isLocked,
downloadMedatadaFromWeb,
saveMetadataInMediaDirectories
saveMetadataInMediaDirectories,
scanIds?.Select(scanId => ScanId.Create(scanId)).ToList() ?? [ScanId.CreateUnique(), ScanId.CreateUnique()]
);
return library.Value;