mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 14:11:10 +00:00
Adds the test suites for the library path templates and centralizes their resolution in the domain service
This commit is contained in:
1 parent
ca4f308b0a
commit
7ed6f05632
52 files changed
+4724
-40
No files matched your search
+4
-7
@@ -120,12 +120,9 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
Result<IReadOnlyList<LibraryPathPart>> pathTemplatePartsResult = command.PathTemplateParts.ToDomainParts();
|
||||
if (pathTemplatePartsResult.IsFailure)
|
||||
return pathTemplatePartsResult.Errors;
|
||||
LibraryPathTemplate pathTemplate = command.PathTemplateParts is null
|
||||
? _pathTemplateService.GetDefaultTemplate(libraryType)
|
||||
: LibraryPathTemplate.Create(pathTemplatePartsResult.Value);
|
||||
Result<Success> validatePathTemplateResult = _pathTemplateService.Validate(libraryType, pathTemplate);
|
||||
if (validatePathTemplateResult.IsFailure)
|
||||
return validatePathTemplateResult.Errors;
|
||||
Result<LibraryPathTemplate> pathTemplateResult = _pathTemplateService.ResolveTemplate(libraryType, pathTemplatePartsResult.Value);
|
||||
if (pathTemplateResult.IsFailure)
|
||||
return pathTemplateResult.Errors;
|
||||
|
||||
// Create a domain library object.
|
||||
Result<Library> createLibraryResult = Library.Create(
|
||||
@@ -139,7 +136,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
command.CanDownloadMetadataFromWeb,
|
||||
command.ShouldSaveMetadataInMediaDirectories,
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplate,
|
||||
pathTemplateResult.Value,
|
||||
[]
|
||||
);
|
||||
|
||||
|
||||
+4
-7
@@ -134,12 +134,9 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
Result<IReadOnlyList<LibraryPathPart>> pathTemplatePartsResult = command.PathTemplateParts.ToDomainParts();
|
||||
if (pathTemplatePartsResult.IsFailure)
|
||||
return pathTemplatePartsResult.Errors;
|
||||
LibraryPathTemplate pathTemplate = command.PathTemplateParts is null
|
||||
? _pathTemplateService.GetDefaultTemplate(newLibraryType)
|
||||
: LibraryPathTemplate.Create(pathTemplatePartsResult.Value);
|
||||
Result<Success> validatePathTemplateResult = _pathTemplateService.Validate(newLibraryType, pathTemplate);
|
||||
if (validatePathTemplateResult.IsFailure)
|
||||
return validatePathTemplateResult.Errors;
|
||||
Result<LibraryPathTemplate> pathTemplateResult = _pathTemplateService.ResolveTemplate(newLibraryType, pathTemplatePartsResult.Value);
|
||||
if (pathTemplateResult.IsFailure)
|
||||
return pathTemplateResult.Errors;
|
||||
|
||||
Result<Library> createLibraryResult = Library.Create(
|
||||
LibraryId.Create(command.Id),
|
||||
@@ -153,7 +150,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
command.CanDownloadMetadataFromWeb,
|
||||
command.ShouldSaveMetadataInMediaDirectories,
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
pathTemplate,
|
||||
pathTemplateResult.Value,
|
||||
[.. getLibraryResult.Value.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))]
|
||||
);
|
||||
if (createLibraryResult.IsFailure)
|
||||
|
||||
Reference in new issue
Block a user