diff --git a/docs/manual/managing-libraries/index.md b/docs/manual/managing-libraries/index.md index 0c1f1688..253df261 100644 --- a/docs/manual/managing-libraries/index.md +++ b/docs/manual/managing-libraries/index.md @@ -51,6 +51,7 @@ Open the Libraries management page, choose to add a library, and fill in the for | Download metadata from the web | on | Whether Lumina may look up the metadata of the items online. This only has an effect when a metadata provider is enabled for the library (see [Plugins](../plugins/index.md)). | | Save metadata in media directories | off | Whether the metadata Lumina fetches is also written next to your media files, so other tools can read it. This is the one option that writes into your media folders. | | Skip unchanged directories during scan | off | An opt-in speedup that skips folders whose own last-modified time has not changed since the last scan. Editing the contents of an existing file in place, without adding, removing or renaming anything in that folder, leaves the folder's time untouched, so that edit can be missed while it is on. | +| Content is on SSD | off | Whether the folders of this library are stored on a solid state drive. When on, the file discovery and content hashing stages read several files at the same time, which is faster on solid state drives. Leave it off for mechanical hard drives, where reading files in parallel can slow the scan down. | | Track consumption progress | the type default | Whether the latest playback or reading position of the library's items is remembered, so a user can resume where they left off. | | Completion threshold | the type default | The percentage of an item that must be consumed for a stopped session to be recorded as completed. Empty means completion is recorded only when it is reported explicitly. | | Path template | the type's ideal structure | Tells Lumina how your folders are arranged on disk. Unless you customize it, it holds the default template of the library type, which is exactly the structure Lumina expects. Optional, and explained in full below. | @@ -119,6 +120,8 @@ Creating a library only records where the media lives. To actually read it, you Lumina is designed to be efficient and performant. The first scan of a library reads and indexes everything it finds, so it is the slowest one. Every scan after that compares what is on disk against the previous scan and only processes what is new or changed, so it is normally much faster. How long any scan takes also depends on what is enabled for the library: metadata and artwork providers that fetch data from the web add network time on top of reading the files, and they do it only for the items that need it. +How the scan reads the files depends on the hardware that stores them. A library whose content is on a solid state drive can discover and hash several files at the same time, so turn on **Content is on SSD** for it. A library on a mechanical hard drive should keep that setting off, because parallel reads make the drive seek back and forth and can make the scan slower. Metadata extraction and artwork resolution still read the files one at a time; this setting only changes file discovery and content hashing. + Scans run on the server in the background, so once one starts you can close the browser and come back later. While a scan is running, its progress is shown live: how far along it is overall, how many items it has processed, and the operation it is currently on. A scan is queued before it starts, then runs, and ends up finished, cancelled or failed. You can cancel a running scan at any time, for one library or for all of them. @@ -190,6 +193,7 @@ These are per user settings, each user changes their own from the settings page - **`Save metadata in media directories` writes into your media folders.** It is off by default; turn it on only if you want metadata files to accompany your media. - **`Skip unchanged directories during scan` can miss in-place edits.** It trusts each folder's own last-modified time, so editing the contents of an existing file without adding, removing or renaming anything in its folder leaves the folder unchanged and it gets skipped. Adding, removing or renaming a file does change the folder, and is still seen. +- **`Content is on SSD` changes how file discovery and content hashing read files.** Turn it on only when the folders of the library really are on a solid state drive. On a mechanical hard drive, parallel reads can make those stages slower than sequential ones. - **`Locked` blocks everything.** A locked library is not scanned and not updated, including by the scheduler. - **`Disabled` hides the library.** A disabled library is neither shown on the dashboard nor touched. - **Deleting a library removes Lumina's catalogue for it.** The files remain, but the metadata and artwork Lumina held for that library do not. Consumption history and resume points are kept as records of what was consumed. The history shows the items as unavailable until you delete it. **Remove from continue watching** removes every resume point of the selected user, not only the ones from the deleted library. diff --git a/docs/technical/api/library/management/Api.Libraries.md b/docs/technical/api/library/management/Api.Libraries.md index 93dc2a0f..26e3807c 100644 --- a/docs/technical/api/library/management/Api.Libraries.md +++ b/docs/technical/api/library/management/Api.Libraries.md @@ -65,6 +65,7 @@ POST api/v1/libraries "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [] @@ -92,6 +93,7 @@ POST api/v1/libraries "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [], @@ -130,6 +132,7 @@ GET api/v1/libraries "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [], @@ -169,6 +172,7 @@ GET api/v1/libraries/enabled "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [], @@ -207,6 +211,7 @@ GET api/v1/libraries/{id} "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [], @@ -238,6 +243,7 @@ PUT api/v1/libraries/{id} "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [] @@ -265,6 +271,7 @@ PUT api/v1/libraries/{id} "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [], diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0019.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0019.md new file mode 100644 index 00000000..3385708e --- /dev/null +++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0019.md @@ -0,0 +1,71 @@ +# Architecture Decision Record (ADR): 0019 - SSD Aware Read Parallelism During Media Library Scans + +## Status + +**Accepted** (2026-10-30) + +## Context + +A media library scan performs two kinds of file system reads. Discovery reads directory entries and file metadata, and hashing samples file contents. Their throughput depends on the storage medium. A solid state drive serves concurrent reads with little penalty, while a mechanical hard drive pays a seek for every position change, so concurrent reads can reduce its throughput. + +Lumina cannot determine the storage medium reliably. Drive type queries are platform specific, and they are unreliable for network, virtual, and removable volumes. The scan therefore needs an explicit input instead of an automatic guess. + +Not every scan stage performs bulk local reads. Audio metadata extraction parses tag blocks, and metadata and artwork enrichment call remote providers. Those stages have their own constraints, which are part of this decision. + +## Decision + +Add an `IsContentOnSsd` boolean to the `Library` aggregate, **off by default**. It is stored in the `Libraries` table with a default value of `false` and exposed through the library form and API contracts. + +The setting controls read parallelism in the two stages that perform bulk local reads: + +- **File system discovery**: the book and music discovery jobs read the sizes and last write times of the files of each directory in parallel when the option is on, and sequentially when it is off. Discovered files and directory fingerprints are still merged and written to the repositories sequentially, because the repositories are not thread-safe. +- **File hashing**: `MediaLibraryScanHashJob` reads `IsContentOnSsd` without loading the content location or path template graph, and passes it to `IFileHashService.HashFilesAsync`. The service uses `MaxDegreeOfParallelism = Environment.ProcessorCount` when the option is on, and `MaxDegreeOfParallelism = 1` when it is off. + +The following stages keep their current sequencing: + +- **Audio metadata extraction**: extraction and persistence are interleaved on one `IUnitOfWork` and `DbContext`, which is not thread-safe. Parallelizing it requires a bounded producer and consumer split, with extraction on worker threads and all repository writes on one thread. +- **Metadata and artwork enrichment**: these stages are network bound, and the providers already have process-wide request throttles. Item level parallelism would mostly queue on those throttles, and it is a provider concurrency concern rather than a storage medium concern. + +The setting does not change the stored catalogue or the result of a scan. It only changes how discovery and hashing read the files, so a change takes effect on the next scan and never requires a rehash of unchanged files. + +## Consequences + +### Positive Outcomes + +| Aspect | Benefit | +|---|---| +| Explicit choice | The scan never guesses the storage medium from platform specific or unreliable drive queries | +| Off by default | Existing libraries keep sequential reads, and mechanical drives are never slowed down by an upgrade | +| Bounded memory | Parallel reads are merged before batching, so staging results and directory fingerprints keep their existing batch size and memory profile | +| Cheap hashing lookup | The hashing job reads only the scalar setting, without tracking the library or loading its navigation properties | + +### Risks and Tradeoffs + +| Risk | Mitigation Strategy | +|---|---| +| A user enables the option on a mechanical drive | The option label and description state that it is meant for solid state drives, and the manual repeats the warning | +| The option can be forgotten after moving a library to another drive | It is editable on the existing library, and it takes effect on the next scan | +| The content locations of one library can be mixed across solid state and mechanical drives | The option describes the library as a whole. Keep it off when any content location is on a mechanical drive, or split the locations into separate libraries when the difference matters | +| Parallel metadata reads on a directory with many files allocate the metadata array for that directory | Only one directory is processed at a time, and the array is merged into the existing bounded staging batches as soon as it is ready | +| Metadata extraction and enrichment do not benefit from the setting | They are documented as separate stages with their own constraints, and the option description names only file discovery and content hashing | +| Discovery reads and hashing run in parallel, but enrichment still waits on provider throttles | The setting is scoped to local read throughput and does not claim to speed up network bound stages | + +## Alternatives Considered + +### 1. Always read in parallel + +Keep the previous `Environment.ProcessorCount` behavior for every scan and do not expose a setting. + +**Rejected**: mechanical drives can become slower with concurrent reads. + +### 2. Detect the storage medium automatically + +Query the operating system for the drive type of each content location and choose the parallelism accordingly. + +**Rejected**: the detection is platform specific, unreliable for network and virtual volumes, and would hide the choice from the user. + +### 3. Parallelize metadata extraction and enrichment under the same setting + +Use the same flag to parallelize audio metadata extraction, metadata enrichment, and artwork resolution. + +**Rejected for now**: extraction needs a bounded producer and consumer refactor around the non-thread-safe `DbContext`, and enrichment is network bound behind process-wide provider throttles. Both are separate concerns from the read behavior of the storage medium. diff --git a/docs/technical/requests/library/management/AddLibrary.http b/docs/technical/requests/library/management/AddLibrary.http index 5b09ae1c..57ca97a3 100644 --- a/docs/technical/requests/library/management/AddLibrary.http +++ b/docs/technical/requests/library/management/AddLibrary.http @@ -14,6 +14,7 @@ Content-Type: application/json "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [ diff --git a/docs/technical/requests/library/management/UpdateLibrary.http b/docs/technical/requests/library/management/UpdateLibrary.http index 2733e7d1..63065f1f 100644 --- a/docs/technical/requests/library/management/UpdateLibrary.http +++ b/docs/technical/requests/library/management/UpdateLibrary.http @@ -16,6 +16,7 @@ Content-Type: application/json "canDownloadMetadataFromWeb": true, "shouldSaveMetadataInMediaDirectories": true, "shouldSkipUnchangedDirectoriesDuringScan": true, + "isContentOnSsd": false, "shouldTrackConsumptionProgress": true, "completionThresholdPercentage": 100, "pathTemplateParts": [ diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs index 1abed50d..04abb7b8 100644 --- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs +++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs @@ -80,6 +80,11 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity /// public bool ShouldSkipUnchangedDirectoriesDuringScan { get; init; } + /// + /// Gets whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. + /// + public bool IsContentOnSsd { get; init; } + /// /// Gets a value indicating whether the consumption progress of the media library items is tracked. /// diff --git a/src/Lumina.Application/Common/Infrastructure/Security/IFileHashService.cs b/src/Lumina.Application/Common/Infrastructure/Security/IFileHashService.cs index d6326591..fba9bd38 100644 --- a/src/Lumina.Application/Common/Infrastructure/Security/IFileHashService.cs +++ b/src/Lumina.Application/Common/Infrastructure/Security/IFileHashService.cs @@ -17,10 +17,11 @@ public interface IFileHashService /// Hashes by sampling chunks from them. /// /// The collection of files to hash. + /// Whether the files should be read in parallel. Parallel reads benefit solid state drives, while mechanical hard drives are faster with sequential reads. /// Callback to invoke during processing of elements. /// Cancellation token that can be used to stop the execution. /// A collection of the hashed files, along with their hashes. - Task> HashFilesAsync(IReadOnlyCollection files, Func callback, CancellationToken cancellationToken); + Task> HashFilesAsync(IReadOnlyCollection files, bool shouldParallelizeReads, Func callback, CancellationToken cancellationToken); /// /// Computes the content hash of the file stored at , by sampling chunks from it. diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs index 0005fa63..0c62bc02 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs @@ -29,6 +29,7 @@ public static class AddMediaLibraryRequestMapping request.CanDownloadMetadataFromWeb, request.ShouldSaveMetadataInMediaDirectories, request.ShouldSkipUnchangedDirectoriesDuringScan, + request.IsContentOnSsd, request.ShouldTrackConsumptionProgress, request.CompletionThresholdPercentage, request.PathTemplateParts?.Select(part => new LibraryPathTemplatePartDto(part.Kind, part.Representation, part.IsOptional)).ToArray() diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs index 52e3d970..aed072db 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs @@ -36,6 +36,7 @@ public static class LibraryEntityMapping repositoryEntity.CanDownloadMetadataFromWeb, repositoryEntity.ShouldSaveMetadataInMediaDirectories, repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan, + repositoryEntity.IsContentOnSsd, repositoryEntity.ShouldTrackConsumptionProgress, repositoryEntity.CompletionThresholdPercentage, [.. repositoryEntity.PathTemplateParts @@ -73,6 +74,7 @@ public static class LibraryEntityMapping repositoryEntity.CanDownloadMetadataFromWeb, repositoryEntity.ShouldSaveMetadataInMediaDirectories, repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan, + repositoryEntity.IsContentOnSsd, consumptionSettings, pathTemplateResult.Value, [.. repositoryEntity.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))] diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs index deeb00d9..9d61a1b1 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs @@ -39,6 +39,7 @@ public static class LibraryMapping CanDownloadMetadataFromWeb = domainEntity.CanDownloadMetadataFromWeb, ShouldSaveMetadataInMediaDirectories = domainEntity.ShouldSaveMetadataInMediaDirectories, ShouldSkipUnchangedDirectoriesDuringScan = domainEntity.ShouldSkipUnchangedDirectoriesDuringScan, + IsContentOnSsd = domainEntity.IsContentOnSsd, ShouldTrackConsumptionProgress = domainEntity.ConsumptionSettings.ShouldTrackConsumptionProgress, CompletionThresholdPercentage = domainEntity.ConsumptionSettings.CompletionThresholdPercentage.HasValue ? domainEntity.ConsumptionSettings.CompletionThresholdPercentage.Value diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs index dcc62c28..6ab4c212 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs @@ -31,6 +31,7 @@ public static class UpdateLibraryRequestMapping request.CanDownloadMetadataFromWeb, request.ShouldSaveMetadataInMediaDirectories, request.ShouldSkipUnchangedDirectoriesDuringScan, + request.IsContentOnSsd, request.ShouldTrackConsumptionProgress, request.CompletionThresholdPercentage, request.PathTemplateParts?.Select(part => new LibraryPathTemplatePartDto(part.Kind, part.Representation, part.IsOptional)).ToArray() diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs index 98a3a3c6..6b013e07 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs @@ -18,6 +18,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary; /// Whether this media library should update the metadata of its elements from the web, or not. /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. /// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. +/// Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. /// Whether the consumption progress of the media library items should be tracked, or not. When absent, the default of the library type is used. /// The percentage of a media library item that must be consumed for its session to be considered completed. When absent, the default of the library type is used on creation. /// The ordered parts of the template describing the structure of the media library on disk. @@ -32,6 +33,7 @@ public record AddLibraryCommand( bool CanDownloadMetadataFromWeb, bool ShouldSaveMetadataInMediaDirectories, bool ShouldSkipUnchangedDirectoriesDuringScan, + bool IsContentOnSsd, bool? ShouldTrackConsumptionProgress, int? CompletionThresholdPercentage, LibraryPathTemplatePartDto[]? PathTemplateParts diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs index d6c2fb97..1a4cf50b 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs @@ -147,6 +147,7 @@ public class AddLibraryCommandHandler : ICommandHandlerWhether this media library should update the metadata of its elements from the web, or not. /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. /// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. +/// Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. /// Whether the consumption progress of the media library items should be tracked, or not. When absent, the stored value is kept. /// The percentage of a media library item that must be consumed for its session to be considered completed. When absent, the stored value is kept. /// The ordered parts of the template describing the structure of the media library on disk. @@ -37,6 +38,7 @@ public record UpdateLibraryCommand( bool CanDownloadMetadataFromWeb, bool ShouldSaveMetadataInMediaDirectories, bool ShouldSkipUnchangedDirectoriesDuringScan, + bool IsContentOnSsd, bool? ShouldTrackConsumptionProgress, int? CompletionThresholdPercentage, LibraryPathTemplatePartDto[]? PathTemplateParts diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs index 7ad62473..b77a417c 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs @@ -169,6 +169,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler ScanId.Create(libraryScan.Id))] diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs index 68246693..6daf08ed 100644 --- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs +++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs @@ -16,6 +16,7 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management; /// Whether this media library should update the metadata of its elements from the web, or not. Optional. /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional. /// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional. +/// Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. Optional. /// Whether the consumption progress of the media library items should be tracked, or not. Optional, the default of the library type is used when absent. /// The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the default of the library type is used when absent. /// The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent. @@ -30,6 +31,7 @@ public record AddLibraryRequest( bool CanDownloadMetadataFromWeb, bool ShouldSaveMetadataInMediaDirectories, bool ShouldSkipUnchangedDirectoriesDuringScan, + bool IsContentOnSsd, bool? ShouldTrackConsumptionProgress, int? CompletionThresholdPercentage, LibraryPathTemplatePartRequest[]? PathTemplateParts diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs index 6e967af2..9d4377f2 100644 --- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs +++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs @@ -19,6 +19,7 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management; /// Whether this media library should update the metadata of its elements from the web, or not. Optional. /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. /// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional. +/// Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. Optional. /// Whether the consumption progress of the media library items should be tracked, or not. Optional, the stored value is kept when absent. /// The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the stored value is kept when absent. /// The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent. @@ -35,6 +36,7 @@ public record class UpdateLibraryRequest( bool CanDownloadMetadataFromWeb, bool ShouldSaveMetadataInMediaDirectories, bool ShouldSkipUnchangedDirectoriesDuringScan, + bool IsContentOnSsd, bool? ShouldTrackConsumptionProgress, int? CompletionThresholdPercentage, LibraryPathTemplatePartRequest[]? PathTemplateParts diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs index 2486f5c2..beb55747 100644 --- a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs +++ b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs @@ -21,6 +21,7 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management; /// Whether the media library should update the metadata of its elements from the web, or not. /// Whether the media library should copy the downloaded metadata into the media library content locations, or not. /// Whether the media library should skip the directories whose contents have not changed since the last scan, during the scan. +/// Whether the content of the media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. /// Whether the consumption progress of the media library items is tracked. /// The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled. /// The ordered parts of the template describing the structure of the media library on disk. @@ -39,6 +40,7 @@ public record LibraryResponse( bool CanDownloadMetadataFromWeb, bool ShouldSaveMetadataInMediaDirectories, bool ShouldSkipUnchangedDirectoriesDuringScan, + bool IsContentOnSsd, bool ShouldTrackConsumptionProgress, int? CompletionThresholdPercentage, List PathTemplateParts, diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs index 65e5ee8a..3f768e45 100644 --- a/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs +++ b/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs @@ -79,6 +79,10 @@ public class LibraryConfiguration : IEntityTypeConfiguration .HasDefaultValue(null) .HasColumnOrder(17); + builder.Property(library => library.IsContentOnSsd) + .HasDefaultValue(false) + .HasColumnOrder(18); + // one user with many libraries builder.HasOne(library => library.User) .WithMany(user => user.Libraries) diff --git a/src/Lumina.DataAccess/Common/Migrations/20261030091100_AddsIsContentOnSsdToLibraries.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20261030091100_AddsIsContentOnSsdToLibraries.Designer.cs new file mode 100644 index 00000000..20e7f0d2 --- /dev/null +++ b/src/Lumina.DataAccess/Common/Migrations/20261030091100_AddsIsContentOnSsdToLibraries.Designer.cs @@ -0,0 +1,3902 @@ +// +using System; +using Lumina.DataAccess.Core.UoW; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Lumina.DataAccess.Common.Migrations +{ + [DbContext(typeof(LuminaDbContext))] + [Migration("20261030091100_AddsIsContentOnSsdToLibraries")] + partial class AddsIsContentOnSsdToLibraries + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.11"); + + modelBuilder.Entity("AlbumGenres", b => + { + b.Property("AlbumId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("AlbumId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("AlbumGenres", (string)null); + }); + + modelBuilder.Entity("AlbumTags", b => + { + b.Property("AlbumId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("AlbumId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("AlbumTags", (string)null); + }); + + modelBuilder.Entity("ArtistGenres", b => + { + b.Property("ArtistId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("ArtistId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("ArtistGenres", (string)null); + }); + + modelBuilder.Entity("ArtistTags", b => + { + b.Property("ArtistId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("ArtistId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("ArtistTags", (string)null); + }); + + modelBuilder.Entity("BookGenres", b => + { + b.Property("BookId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("BookId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("BookGenres", (string)null); + }); + + modelBuilder.Entity("BookTags", b => + { + b.Property("BookId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("BookId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("BookTags", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("PermissionName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.HasKey("Id"); + + b.ToTable("Permissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.HasKey("Id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b => + { + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.Property("PermissionId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("RoleId", "PermissionId"); + + b.HasIndex("PermissionId"); + + b.HasIndex("RoleId", "PermissionId") + .IsUnique(); + + b.ToTable("RolePermissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("PermissionId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("UserId", "PermissionId"); + + b.HasIndex("PermissionId"); + + b.HasIndex("UserId", "PermissionId") + .IsUnique(); + + b.ToTable("UserPermissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("UserId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId", "RoleId") + .IsUnique(); + + b.ToTable("UserRoles", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b => + { + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Genres", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b => + { + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Tags", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Favorites.FavoriteEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaItemId") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("MediaKind") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.HasKey("Id"); + + b.HasIndex("UserId", "CreatedOnUtc"); + + b.HasIndex("UserId", "MediaKind", "CreatedOnUtc"); + + b.HasIndex("UserId", "MediaKind", "MediaItemId") + .IsUnique(); + + b.ToTable("Favorites", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaConsumption.MediaConsumptionRecordEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ConsecutivePagesRead") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0) + .HasColumnOrder(14); + + b.Property("ConsumedDurationMilliseconds") + .HasColumnType("INTEGER") + .HasColumnOrder(9); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(17); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("EndedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("LastActivityOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("LastPositionKind") + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("LastPositionLocation") + .HasMaxLength(4096) + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("LastPositionTimeOffsetMilliseconds") + .HasColumnType("INTEGER") + .HasColumnOrder(11); + + b.Property("LastProgressFraction") + .HasColumnType("REAL") + .HasColumnOrder(13); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MediaItemId") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("MediaKind") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("StartedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Version") + .IsConcurrencyToken() + .HasColumnType("INTEGER") + .HasColumnOrder(15); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MediaKind", "StartedOnUtc"); + + b.HasIndex("UserId", "MediaKind", "MediaItemId", "LastActivityOnUtc"); + + b.ToTable("MediaConsumptionRecords", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaConsumption.MediaResumePointEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("LastConsumedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("LastPositionKind") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("LastPositionLocation") + .HasMaxLength(4096) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("LastPositionTimeOffsetMilliseconds") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("LastProgressFraction") + .HasColumnType("REAL") + .HasColumnOrder(8); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MediaItemId") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaKind") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Version") + .IsConcurrencyToken() + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.HasKey("Id"); + + b.HasIndex("UserId", "MediaKind", "MediaItemId") + .IsUnique(); + + b.ToTable("MediaResumePoints", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaContributors.MediaContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Biography") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("DateOfBirth") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("DateOfDeath") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1) + .UseCollation("NOCASE"); + + b.Property("LegalName") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.HasKey("Id"); + + b.HasIndex("DisplayName") + .IsUnique(); + + b.ToTable("MediaContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("AlbumId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaContributorId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Role") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("MediaContributorId"); + + b.HasIndex("AlbumId", "MediaContributorId", "Role") + .IsUnique(); + + b.ToTable("AlbumContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ASIN") + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(28); + + b.Property("ArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Barcode") + .HasMaxLength(13) + .HasColumnType("TEXT") + .HasColumnOrder(25); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(33); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(32); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Disambiguation") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("Label") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(27); + + b.Property("LanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("LanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("LanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("LastMetadataUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(37); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MediaFormat") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(23); + + b.Property("MetadataProvider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(38); + + b.Property("MetadataStatus") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasDefaultValue("Pending") + .HasColumnOrder(36); + + b.Property("MusicBrainzReleaseArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(31); + + b.Property("MusicBrainzReleaseGroupId") + .HasColumnType("TEXT") + .HasColumnOrder(30); + + b.Property("MusicBrainzReleaseId") + .HasColumnType("TEXT") + .HasColumnOrder(29); + + b.Property("OriginalLanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("OriginalLanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(17); + + b.Property("OriginalLanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("OriginalReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("OriginalReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(8); + + b.Property("OriginalTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("Packaging") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.Property("ReReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("ReReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.Property("ReleaseCountry") + .HasMaxLength(2) + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("ReleaseStatus") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(20); + + b.Property("ReleaseTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(26); + + b.Property("ReleaseVersion") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("Script") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("TotalDiscs") + .HasColumnType("INTEGER") + .HasColumnOrder(21); + + b.Property("TotalTracks") + .HasColumnType("INTEGER") + .HasColumnOrder(22); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(35); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(34); + + b.HasKey("Id"); + + b.HasIndex("ArtistId", "Title"); + + b.HasIndex("LibraryId", "Title"); + + b.ToTable("Albums", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaContributorId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Role") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("MediaContributorId"); + + b.HasIndex("ArtistId", "MediaContributorId", "Role") + .IsUnique(); + + b.ToTable("ArtistContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Country") + .HasMaxLength(2) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("Disambiguation") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("Gender") + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("IsEnded") + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.Property("LastMetadataUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("LifeSpanBegin") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("LifeSpanEnd") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("MetadataProvider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("MetadataStatus") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasDefaultValue("Pending") + .HasColumnOrder(17); + + b.Property("MusicBrainzArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("SortName") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("Type") + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("Website") + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "Name") + .IsUnique(); + + b.ToTable("Artists", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicArtworkEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ArtworkType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("ContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("FileName") + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("LastUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("Ordinal") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("OwnerId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("OwnerType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Provider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.HasIndex("OwnerType", "OwnerId", "ArtworkType", "Ordinal") + .IsUnique(); + + b.ToTable("MusicArtwork", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicLibraryScanItemMetadataEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("AcoustId") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(25); + + b.Property("ArtistName") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("AudioCodec") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("BitDepth") + .HasColumnType("INTEGER") + .HasColumnOrder(14); + + b.Property("Bitrate") + .HasColumnType("INTEGER") + .HasColumnOrder(16); + + b.Property("Channels") + .HasColumnType("INTEGER") + .HasColumnOrder(13); + + b.Property("Container") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(31); + + b.Property("DiscNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.Property("DurationInSeconds") + .HasColumnType("INTEGER") + .HasColumnOrder(11); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("LibraryScanId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.PrimitiveCollection("Moods") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(30); + + b.Property("MusicBrainzArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(17); + + b.Property("MusicBrainzRecordingId") + .HasColumnType("TEXT") + .HasColumnOrder(21); + + b.Property("MusicBrainzReleaseArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("MusicBrainzReleaseGroupId") + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("MusicBrainzReleaseId") + .HasColumnType("TEXT") + .HasColumnOrder(20); + + b.Property("MusicBrainzTrackId") + .HasColumnType("TEXT") + .HasColumnOrder(22); + + b.Property("MusicBrainzWorkId") + .HasColumnType("TEXT") + .HasColumnOrder(23); + + b.Property("Path") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("ReleaseName") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("ReleaseType") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("ReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("ReplayGainAlbumGain") + .HasColumnType("decimal(8,2)") + .HasColumnOrder(28); + + b.Property("ReplayGainAlbumPeak") + .HasColumnType("decimal(8,6)") + .HasColumnOrder(29); + + b.Property("ReplayGainTrackGain") + .HasColumnType("decimal(8,2)") + .HasColumnOrder(26); + + b.Property("ReplayGainTrackPeak") + .HasColumnType("decimal(8,6)") + .HasColumnOrder(27); + + b.Property("SampleRate") + .HasColumnType("INTEGER") + .HasColumnOrder(12); + + b.Property("TrackNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(9); + + b.Property("TrackTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("WorkTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.HasKey("Id"); + + b.HasIndex("LibraryScanId", "Path") + .IsUnique(); + + b.ToTable("MusicLibraryScanItemMetadata", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaContributorId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Role") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("TrackId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("MediaContributorId"); + + b.HasIndex("TrackId", "MediaContributorId", "Role") + .IsUnique(); + + b.ToTable("TrackContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("AcoustId") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(44); + + b.Property("AlbumId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("AudioCodec") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.Property("BitDepth") + .HasColumnType("INTEGER") + .HasColumnOrder(23); + + b.Property("Bitrate") + .HasColumnType("INTEGER") + .HasColumnOrder(25); + + b.Property("Bpm") + .HasColumnType("INTEGER") + .HasColumnOrder(30); + + b.Property("Channels") + .HasColumnType("INTEGER") + .HasColumnOrder(22); + + b.Property("Container") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(49); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(38); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(37); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("Disambiguation") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("DiscNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(27); + + b.Property("DurationInSeconds") + .HasColumnType("INTEGER") + .HasColumnOrder(20); + + b.Property("IsVideo") + .HasColumnType("INTEGER") + .HasColumnOrder(31); + + b.Property("Key") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(29); + + b.Property("LanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("LanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("LanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("LastMetadataUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(42); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MetadataProvider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(43); + + b.Property("MetadataStatus") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasDefaultValue("Pending") + .HasColumnOrder(41); + + b.Property("MusicBrainzRecordingId") + .HasColumnType("TEXT") + .HasColumnOrder(34); + + b.Property("MusicBrainzTrackId") + .HasColumnType("TEXT") + .HasColumnOrder(35); + + b.Property("MusicBrainzWorkId") + .HasColumnType("TEXT") + .HasColumnOrder(36); + + b.Property("OriginalLanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(17); + + b.Property("OriginalLanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("OriginalLanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("OriginalReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("OriginalReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(9); + + b.Property("OriginalTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Path") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("ReReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("ReReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(11); + + b.Property("ReleaseCountry") + .HasMaxLength(2) + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("ReleaseVersion") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("ReplayGainAlbumGain") + .HasColumnType("decimal(8,2)") + .HasColumnOrder(47); + + b.Property("ReplayGainAlbumPeak") + .HasColumnType("decimal(8,6)") + .HasColumnOrder(48); + + b.Property("ReplayGainTrackGain") + .HasColumnType("decimal(8,2)") + .HasColumnOrder(45); + + b.Property("ReplayGainTrackPeak") + .HasColumnType("decimal(8,6)") + .HasColumnOrder(46); + + b.Property("SampleRate") + .HasColumnType("INTEGER") + .HasColumnOrder(21); + + b.Property("Script") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(28); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("TrackNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(26); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(40); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(39); + + b.Property("WorkTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(32); + + b.Property("WorkType") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(33); + + b.HasKey("Id"); + + b.HasIndex("AlbumId", "TrackNumber"); + + b.HasIndex("LibraryId", "Path") + .IsUnique(); + + b.ToTable("Tracks", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b => + { + b.Property("LibraryId") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasMaxLength(1024) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("LastWriteTimeUtc") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.HasKey("LibraryId", "Path"); + + b.HasIndex("LibraryId"); + + b.ToTable("DirectoryScanFingerprints", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ArtworkProvidersConfigurationFingerprint") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("CanDownloadMetadataFromWeb") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnOrder(6); + + b.Property("CompletionThresholdPercentage") + .HasColumnType("INTEGER") + .HasColumnOrder(17); + + b.Property("CoverImage") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("IsContentOnSsd") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(false) + .HasColumnOrder(18); + + b.Property("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnOrder(4); + + b.Property("IsLocked") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("LibraryType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MetadataProvidersConfigurationFingerprint") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("PathTemplateFingerprint") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("ShouldSaveMetadataInMediaDirectories") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("ShouldSkipUnchangedDirectoriesDuringScan") + .HasColumnType("INTEGER") + .HasColumnOrder(8); + + b.Property("ShouldTrackConsumptionProgress") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(false) + .HasColumnOrder(16); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Libraries", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("LibraryId") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("LibraryId", "Status", "CreatedOnUtc") + .IsDescending(true, false, true); + + b.ToTable("LibraryScans", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b => + { + b.Property("LibraryScanId") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasMaxLength(1024) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("ContentHash") + .HasMaxLength(24) + .HasColumnType("INTEGER") + .HasColumnOrder(2); + + b.Property("FileSize") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Status") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Ticks") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.HasKey("LibraryScanId", "Path"); + + b.HasIndex("Path"); + + b.HasIndex("ContentHash", "FileSize", "Path"); + + b.ToTable("LibraryScanResults", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanSnapshotEntity", b => + { + b.Property("LibraryId") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasMaxLength(1024) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("ContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(2); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("FileSize") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Ticks") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.HasKey("LibraryId", "Path"); + + b.HasIndex("LibraryId"); + + b.ToTable("LibraryScanSnapshots", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanStagingResultsEntity", b => + { + b.Property("LibraryScanId") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasMaxLength(1024) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("ContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("IsNew") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("NeedsRehash") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("PreviousContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("Size") + .HasColumnType("INTEGER") + .HasColumnOrder(2); + + b.Property("Ticks") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.HasKey("LibraryScanId", "Path"); + + b.HasIndex("LibraryScanId", "NeedsRehash"); + + b.ToTable("LibraryScanStagingResults", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookArtworkEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ArtworkType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("BookId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("ContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("FileName") + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("LastUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Ordinal") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("Provider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.HasIndex("BookId", "ArtworkType", "Ordinal") + .IsUnique(); + + b.ToTable("BookArtwork", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("BookId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaContributorId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Role") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("MediaContributorId"); + + b.HasIndex("BookId", "MediaContributorId", "Role") + .IsUnique(); + + b.ToTable("BookContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ASIN") + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnOrder(21); + + b.Property("AppleBooksId") + .HasColumnType("TEXT") + .HasColumnOrder(29); + + b.Property("BarnesAndNobleId") + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnOrder(28); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(33); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(32); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("Edition") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("Format") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("GoodreadsId") + .HasColumnType("TEXT") + .HasColumnOrder(22); + + b.Property("GoogleBooksId") + .HasMaxLength(12) + .HasColumnType("TEXT") + .HasColumnOrder(27); + + b.Property("LCCN") + .HasColumnType("TEXT") + .HasColumnOrder(23); + + b.Property("LanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("LanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("LanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("LastMetadataUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(39); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(36); + + b.Property("LibraryThingId") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(26); + + b.Property("MetadataProvider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(40); + + b.Property("MetadataStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(38); + + b.Property("OCLCNumber") + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.Property("OpenLibraryId") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(25); + + b.Property("OriginalLanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("OriginalLanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("OriginalLanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("OriginalReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("OriginalReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("OriginalTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("PageCount") + .HasColumnType("INTEGER") + .HasColumnOrder(17); + + b.Property("Path") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(37); + + b.Property("Publisher") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("ReReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("ReReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("ReleaseCountry") + .HasMaxLength(2) + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("ReleaseVersion") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(35); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(34); + + b.Property("VolumeNumber") + .HasColumnType("REAL") + .HasColumnOrder(20); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "MetadataStatus"); + + b.HasIndex("LibraryId", "Path") + .IsUnique(); + + b.ToTable("Books", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("EntryCount") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0) + .HasColumnOrder(10); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Type") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0L) + .HasColumnOrder(9); + + b.HasKey("Id"); + + b.HasIndex("UserId", "UpdatedOnUtc"); + + b.ToTable("Playlists", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntryEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("MediaItemId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MediaItemType") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("PlaylistId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Position") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.HasKey("Id"); + + b.HasIndex("MediaItemId"); + + b.HasIndex("PlaylistId", "Position") + .IsUnique(); + + b.ToTable("PlaylistEntries", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryArtworkProviderConfigurationEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("IsEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("PluginId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Rank") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "PluginId"); + + b.ToTable("LibraryArtworkProviderConfigurations", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryBookReaderConfigurationEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("IsEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("PluginId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "PluginId") + .IsUnique(); + + b.ToTable("LibraryBookReaderConfigurations", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryMetadataProviderConfigurationEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("IsEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("PluginId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Rank") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "PluginId"); + + b.ToTable("LibraryMetadataProviderConfigurations", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.PluginEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Author") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("LoadError") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("LoadStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("SettingsJson") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("Version") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("Id"); + + b.ToTable("Plugins", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Scheduling.ScheduledJobEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("Hour") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("IntervalMinutes") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("LastCompletedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("LastStartedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("Minute") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("OwnerUserId") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("ScheduleType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("Status") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("TaskType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.ToTable("ScheduledJobs", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Scheduling.ScheduledJobExecutionEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CompletedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("IsCycleRun") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("ScheduledJobId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("StartedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("TaskType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("WasCycleActive") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("ScheduledJobId"); + + b.HasIndex("StartedOnUtc", "ScheduledJobId"); + + b.ToTable("ScheduledJobExecutions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Scheduling.SchedulerDisplayPreferencesEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("DisplayTimeSpan") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("DisplayTimeUnit") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("JobTypeFilter") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("SchedulerDisplayPreferences", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Themes.ThemeEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Author") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("Description") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("InstallSource") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("InstalledAtUtc") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("IsCurrent") + .HasColumnType("INTEGER") + .HasColumnOrder(8); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(false) + .HasColumnOrder(9); + + b.Property("Name") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("PreviewPath") + .HasMaxLength(240) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("ThemeId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("Version") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.HasKey("Id"); + + b.HasIndex("IsCurrent") + .IsUnique() + .HasFilter("IsCurrent = 1"); + + b.HasIndex("ThemeId") + .IsUnique(); + + b.ToTable("Themes", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("TempPassword") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("TempPasswordCreated") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("TotpSecret") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Username") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.HasKey("Id"); + + b.HasIndex("Username") + .IsUnique(); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserSettingsEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("IsGaplessPlaybackEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(16); + + b.Property("IsMuted") + .HasColumnType("INTEGER") + .HasColumnOrder(29); + + b.Property("IsPaginationEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(2); + + b.Property("IsThemeCachingEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(9); + + b.Property("ItemsPerPage") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("ReplayGainMode") + .HasColumnType("INTEGER") + .HasColumnOrder(17); + + b.Property("ShouldAggregateArtworkWhenMissing") + .HasColumnType("INTEGER") + .HasColumnOrder(13); + + b.Property("ShouldAggregateMetadataWhenMissing") + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.Property("ShouldAutoplay") + .HasColumnType("INTEGER") + .HasColumnOrder(15); + + b.Property("ShouldIgnoreThePrefixForAlphaPicker") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("ShouldKeepDownloadingWhilePaused") + .HasColumnType("INTEGER") + .HasColumnOrder(14); + + b.Property("ShouldPreserveBookStyles") + .HasColumnType("INTEGER") + .HasColumnOrder(12); + + b.Property("ShouldRenderPdfAsImages") + .HasColumnType("INTEGER") + .HasColumnOrder(11); + + b.Property("StreamingQuality") + .HasColumnType("INTEGER") + .HasColumnOrder(18); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Volume") + .HasColumnType("REAL") + .HasColumnOrder(28); + + b.Property("VuMeterHighThreshold") + .HasColumnType("REAL") + .HasColumnOrder(23); + + b.Property("VuMeterMediumThreshold") + .HasColumnType("REAL") + .HasColumnOrder(22); + + b.Property("VuMeterOrientation") + .HasColumnType("INTEGER") + .HasColumnOrder(19); + + b.Property("VuMeterPeakHoldDurationInMilliseconds") + .HasColumnType("INTEGER") + .HasColumnOrder(25); + + b.Property("VuMeterPeakReleasePerSecond") + .HasColumnType("REAL") + .HasColumnOrder(27); + + b.Property("VuMeterReleasePerSecond") + .HasColumnType("REAL") + .HasColumnOrder(26); + + b.Property("VuMeterSegmentCount") + .HasColumnType("INTEGER") + .HasColumnOrder(20); + + b.Property("VuMeterSegmentGap") + .HasColumnType("INTEGER") + .HasColumnOrder(21); + + b.Property("VuMeterShowPeak") + .HasColumnType("INTEGER") + .HasColumnOrder(24); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("UserSettings", (string)null); + }); + + modelBuilder.Entity("TrackGenres", b => + { + b.Property("TrackId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("TrackId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("TrackGenres", (string)null); + }); + + modelBuilder.Entity("TrackTags", b => + { + b.Property("TrackId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("TrackId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("TrackTags", (string)null); + }); + + modelBuilder.Entity("AlbumGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", null) + .WithMany() + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AlbumTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", null) + .WithMany() + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ArtistGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", null) + .WithMany() + .HasForeignKey("ArtistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ArtistTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", null) + .WithMany() + .HasForeignKey("ArtistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BookGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany() + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BookTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany() + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission") + .WithMany("RolePermissions") + .HasForeignKey("PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role") + .WithMany("RolePermissions") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission") + .WithMany("UserPermissions") + .HasForeignKey("PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithMany("UserPermissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithOne("UserRole") + .HasForeignKey("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Favorites.FavoriteEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaConsumption.MediaConsumptionRecordEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaConsumption.MediaResumePointEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumContributorEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", null) + .WithMany("Contributors") + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", "Artist") + .WithMany("Albums") + .HasForeignKey("ArtistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumCatalogNumberEntity", "CatalogNumbers", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("AlbumId") + .HasColumnType("TEXT"); + + b1.Property("CatalogNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("AlbumId"); + + b1.ToTable("AlbumCatalogNumbers", (string)null); + + b1.WithOwner() + .HasForeignKey("AlbumId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AudioRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("AlbumId") + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("AlbumId"); + + b1.ToTable("AlbumRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("AlbumId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumReleaseTypeEntity", "ReleaseTypes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("AlbumId") + .HasColumnType("TEXT"); + + b1.Property("ReleaseType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("AlbumId"); + + b1.ToTable("AlbumReleaseTypes", (string)null); + + b1.WithOwner() + .HasForeignKey("AlbumId"); + }); + + b.Navigation("Artist"); + + b.Navigation("CatalogNumbers"); + + b.Navigation("Ratings"); + + b.Navigation("ReleaseTypes"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistContributorEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", null) + .WithMany("Contributors") + .HasForeignKey("ArtistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", b => + { + b.OwnsOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicAreaEntity", "Area", b1 => + { + b1.Property("ArtistEntityId"); + + b1.Property("Disambiguation"); + + b1.Property("Iso3166Code"); + + b1.Property("MusicBrainzAreaId"); + + b1.Property("Name") + .IsRequired(); + + b1.Property("SortName"); + + b1.Property("Type"); + + b1.HasKey("ArtistEntityId"); + + b1.ToTable("Artists"); + + b1 + .ToJson("Area") + .HasColumnType("TEXT"); + + b1.WithOwner() + .HasForeignKey("ArtistEntityId"); + }); + + b.OwnsOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicAreaEntity", "BeginArea", b1 => + { + b1.Property("ArtistEntityId"); + + b1.Property("Disambiguation"); + + b1.Property("Iso3166Code"); + + b1.Property("MusicBrainzAreaId"); + + b1.Property("Name") + .IsRequired(); + + b1.Property("SortName"); + + b1.Property("Type"); + + b1.HasKey("ArtistEntityId"); + + b1.ToTable("Artists"); + + b1 + .ToJson("BeginArea") + .HasColumnType("TEXT"); + + b1.WithOwner() + .HasForeignKey("ArtistEntityId"); + }); + + b.OwnsOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicAreaEntity", "EndArea", b1 => + { + b1.Property("ArtistEntityId"); + + b1.Property("Disambiguation"); + + b1.Property("Iso3166Code"); + + b1.Property("MusicBrainzAreaId"); + + b1.Property("Name") + .IsRequired(); + + b1.Property("SortName"); + + b1.Property("Type"); + + b1.HasKey("ArtistEntityId"); + + b1.ToTable("Artists"); + + b1 + .ToJson("EndArea") + .HasColumnType("TEXT"); + + b1.WithOwner() + .HasForeignKey("ArtistEntityId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistAliasEntity", "Aliases", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("ArtistId") + .HasColumnType("TEXT"); + + b1.Property("BeginDate") + .HasColumnType("TEXT"); + + b1.Property("EndDate") + .HasColumnType("TEXT"); + + b1.Property("IsEnded") + .HasColumnType("INTEGER"); + + b1.Property("IsPrimary") + .HasColumnType("INTEGER"); + + b1.Property("Locale") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b1.Property("SortName") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b1.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("ArtistId"); + + b1.ToTable("ArtistAliases", (string)null); + + b1.WithOwner() + .HasForeignKey("ArtistId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AudioRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("ArtistId") + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("ArtistId"); + + b1.ToTable("ArtistRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("ArtistId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistIpiEntity", "Ipis", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("ArtistId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("ArtistId"); + + b1.ToTable("ArtistIpis", (string)null); + + b1.WithOwner() + .HasForeignKey("ArtistId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistIsniEntity", "Isnis", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("ArtistId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("ArtistId"); + + b1.ToTable("ArtistIsnis", (string)null); + + b1.WithOwner() + .HasForeignKey("ArtistId"); + }); + + b.Navigation("Aliases"); + + b.Navigation("Area"); + + b.Navigation("BeginArea"); + + b.Navigation("EndArea"); + + b.Navigation("Ipis"); + + b.Navigation("Isnis"); + + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackContributorEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", null) + .WithMany("Contributors") + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", "Album") + .WithMany("Tracks") + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AudioRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackIsrcEntity", "Isrcs", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(12) + .HasColumnType("TEXT") + .HasColumnName("ISRC"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackIsrcs", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackMoodEntity", "Moods", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackMoods", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackWorkIswcEntity", "WorkIswcs", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackWorkIswcs", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackWorkLanguageEntity", "WorkLanguages", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("LanguageCode") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("TEXT"); + + b1.Property("LanguageName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b1.Property("NativeName") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackWorkLanguages", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.Navigation("Album"); + + b.Navigation("Isrcs"); + + b.Navigation("Moods"); + + b.Navigation("Ratings"); + + b.Navigation("WorkIswcs"); + + b.Navigation("WorkLanguages"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", null) + .WithMany() + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithMany("Libraries") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryContentLocationEntity", "ContentLocations", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("LibraryId") + .HasColumnType("TEXT"); + + b1.Property("Path") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("TEXT") + .HasColumnName("Path"); + + b1.HasKey("Id"); + + b1.HasIndex("LibraryId"); + + b1.ToTable("LibraryContentLocations", (string)null); + + b1.WithOwner() + .HasForeignKey("LibraryId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryPathTemplatePartEntity", "PathTemplateParts", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("IsOptional") + .HasColumnType("INTEGER"); + + b1.Property("Kind") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b1.Property("LibraryId") + .HasColumnType("TEXT"); + + b1.Property("Position") + .HasColumnType("INTEGER") + .HasColumnName("Position"); + + b1.Property("Representation") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("LibraryId", "Position") + .IsUnique(); + + b1.ToTable("LibraryPathTemplateParts", (string)null); + + b1.WithOwner() + .HasForeignKey("LibraryId"); + }); + + b.Navigation("ContentLocations"); + + b.Navigation("PathTemplateParts"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", "Library") + .WithMany("LibraryScans") + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithMany("LibraryScans") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Library"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", "LibraryScan") + .WithMany("LibraryScanResults") + .HasForeignKey("LibraryScanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LibraryScan"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanSnapshotEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", "Library") + .WithMany() + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Library"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanStagingResultsEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", null) + .WithMany() + .HasForeignKey("LibraryScanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookArtworkEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany("Artwork") + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookContributorEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany("Contributors") + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b => + { + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("BookId") + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("BookId"); + + b1.ToTable("BookRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("BookId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.IsbnEntity", "ISBNs", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("BookId") + .HasColumnType("TEXT"); + + b1.Property("Format") + .IsRequired() + .HasMaxLength(6) + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("TEXT") + .HasColumnName("ISBN"); + + b1.HasKey("Id"); + + b1.HasIndex("BookId"); + + b1.ToTable("BookISBNs", (string)null); + + b1.WithOwner() + .HasForeignKey("BookId"); + }); + + b.Navigation("ISBNs"); + + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntryEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntity", null) + .WithMany("Entries") + .HasForeignKey("PlaylistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserSettingsEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", null) + .WithOne() + .HasForeignKey("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserSettingsEntity", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("TrackGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", null) + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("TrackTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", null) + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b => + { + b.Navigation("RolePermissions"); + + b.Navigation("UserPermissions"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b => + { + b.Navigation("RolePermissions"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", b => + { + b.Navigation("Contributors"); + + b.Navigation("Tracks"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", b => + { + b.Navigation("Albums"); + + b.Navigation("Contributors"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", b => + { + b.Navigation("Contributors"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b => + { + b.Navigation("LibraryScans"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b => + { + b.Navigation("LibraryScanResults"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b => + { + b.Navigation("Artwork"); + + b.Navigation("Contributors"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntity", b => + { + b.Navigation("Entries"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b => + { + b.Navigation("Libraries"); + + b.Navigation("LibraryScans"); + + b.Navigation("UserPermissions"); + + b.Navigation("UserRole"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Lumina.DataAccess/Common/Migrations/20261030091100_AddsIsContentOnSsdToLibraries.cs b/src/Lumina.DataAccess/Common/Migrations/20261030091100_AddsIsContentOnSsdToLibraries.cs new file mode 100644 index 00000000..76a0b7ba --- /dev/null +++ b/src/Lumina.DataAccess/Common/Migrations/20261030091100_AddsIsContentOnSsdToLibraries.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Lumina.DataAccess.Common.Migrations +{ + /// + public partial class AddsIsContentOnSsdToLibraries : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsContentOnSsd", + table: "Libraries", + type: "INTEGER", + nullable: false, + defaultValue: false) + .Annotation("Relational:ColumnOrder", 18); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsContentOnSsd", + table: "Libraries"); + } + } +} diff --git a/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs b/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs index f6d75310..7bc06864 100644 --- a/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs +++ b/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs @@ -1521,6 +1521,12 @@ namespace Lumina.DataAccess.Common.Migrations .HasColumnType("TEXT") .HasColumnOrder(12); + b.Property("IsContentOnSsd") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(false) + .HasColumnOrder(18); + b.Property("IsEnabled") .ValueGeneratedOnAdd() .HasColumnType("INTEGER") diff --git a/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs b/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs index 5bc0f89e..95b733fc 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs @@ -76,6 +76,12 @@ public class Library : AggregateRoot /// public bool ShouldSkipUnchangedDirectoriesDuringScan { get; private set; } + /// + /// Gets whether the content of this media library is stored on a solid state drive. When it is, the file discovery and content hashing stages read the files in parallel, + /// which takes advantage of the low latency of solid state drives. Mechanical hard drives keep those reads sequential, because parallel reads can reduce their throughput. + /// + public bool IsContentOnSsd { get; private set; } + /// /// Gets the consumption settings of the media library. /// @@ -111,6 +117,7 @@ public class Library : AggregateRoot /// Whether this media library should update the metadata of its elements from the web, or not. /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. /// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. + /// Whether the content of this media library is stored on a solid state drive. /// The consumption settings of the media library. /// The template describing the structure of the media library on disk. /// The list of objects representing the unique identifier of scans of the media library. @@ -126,6 +133,7 @@ public class Library : AggregateRoot bool canDownloadMetadataFromWeb, bool shouldSaveMetadataInMediaDirectories, bool shouldSkipUnchangedDirectoriesDuringScan, + bool isContentOnSsd, LibraryConsumptionSettings consumptionSettings, LibraryPathTemplate pathTemplate, List scanIds) : base(id) @@ -140,6 +148,7 @@ public class Library : AggregateRoot CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb; ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories; ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan; + IsContentOnSsd = isContentOnSsd; ConsumptionSettings = consumptionSettings; PathTemplate = pathTemplate; _scanIds = scanIds; @@ -158,6 +167,7 @@ public class Library : AggregateRoot /// Whether this media library should update the metadata of its elements from the web, or not. /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. /// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. + /// Whether the content of this media library is stored on a solid state drive. /// The consumption settings of the media library. /// The template describing the structure of the media library on disk. /// The list of objects representing the unique identifier of scans of the media library. @@ -175,6 +185,7 @@ public class Library : AggregateRoot bool canDownloadMetadataFromWeb, bool shouldSaveMetadataInMediaDirectories, bool shouldSkipUnchangedDirectoriesDuringScan, + bool isContentOnSsd, LibraryConsumptionSettings consumptionSettings, LibraryPathTemplate pathTemplate, List scanIds) @@ -200,6 +211,7 @@ public class Library : AggregateRoot canDownloadMetadataFromWeb, shouldSaveMetadataInMediaDirectories, shouldSkipUnchangedDirectoriesDuringScan, + isContentOnSsd, consumptionSettings, pathTemplate, scanIds @@ -220,6 +232,7 @@ public class Library : AggregateRoot /// Whether this media library should update the metadata of its elements from the web, or not. /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. /// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. + /// Whether the content of this media library is stored on a solid state drive. /// The consumption settings of the media library. /// The template describing the structure of the media library on disk. /// The list of objects representing the unique identifier of scans of the media library. @@ -238,6 +251,7 @@ public class Library : AggregateRoot bool canDownloadMetadataFromWeb, bool shouldSaveMetadataInMediaDirectories, bool shouldSkipUnchangedDirectoriesDuringScan, + bool isContentOnSsd, LibraryConsumptionSettings consumptionSettings, LibraryPathTemplate pathTemplate, List scanIds) @@ -263,6 +277,7 @@ public class Library : AggregateRoot canDownloadMetadataFromWeb, shouldSaveMetadataInMediaDirectories, shouldSkipUnchangedDirectoriesDuringScan, + isContentOnSsd, consumptionSettings, pathTemplate, scanIds diff --git a/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/Audio/Music/MusicFileSystemDiscoveryJob.cs b/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/Audio/Music/MusicFileSystemDiscoveryJob.cs index 9e6c6f1e..0e25a0ab 100644 --- a/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/Audio/Music/MusicFileSystemDiscoveryJob.cs +++ b/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/Audio/Music/MusicFileSystemDiscoveryJob.cs @@ -15,11 +15,13 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary; using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; #endregion @@ -41,6 +43,7 @@ internal sealed class MusicFileSystemDiscoveryJob : MediaLibraryScanJob, IMusicF StringComparer.OrdinalIgnoreCase ); private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. @@ -49,9 +52,11 @@ internal sealed class MusicFileSystemDiscoveryJob : MediaLibraryScanJob, IMusicF /// Injected factory for creating scopes in which services are requested. /// See docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0001.md for details. /// - public MusicFileSystemDiscoveryJob(IServiceScopeFactory serviceScopeFactory) + /// Injected logger for the media library scan job. + public MusicFileSystemDiscoveryJob(IServiceScopeFactory serviceScopeFactory, ILogger logger) { _serviceScopeFactory = serviceScopeFactory; + _logger = logger; } /// @@ -116,6 +121,11 @@ internal sealed class MusicFileSystemDiscoveryJob : MediaLibraryScanJob, IMusicF List stagingBatch = []; List fingerprintBatch = []; + // When the library content is stored on a solid state drive, the file system reads of the scan run in parallel. + bool shouldParallelizeReads = domainLibraryResult.Value.IsContentOnSsd; + if (shouldParallelizeReads) + _logger.LogDebug("The content of the media library with Id '{LibraryId}' is stored on a solid state drive, so its file system reads will run in parallel.", LibraryId.Value); + // Get the files for each of the media library content locations. foreach (FileSystemPathId contentLocation in domainLibraryResult.Value.ContentLocations) { @@ -126,6 +136,7 @@ internal sealed class MusicFileSystemDiscoveryJob : MediaLibraryScanJob, IMusicF fileProviderService, directoryProviderService, fingerprintsByPath is not null, + shouldParallelizeReads, fingerprintsByPath, stagingBatch, fingerprintBatch, @@ -189,6 +200,7 @@ internal sealed class MusicFileSystemDiscoveryJob : MediaLibraryScanJob, IMusicF /// The service used to enumerate the files of a directory. /// The service used to enumerate the subdirectories of a directory. /// Whether to skip the directories whose last write time has not changed since the last scan, or not. + /// Whether the file system reads should run in parallel, which benefits solid state drives. /// The directory scan fingerprints of the library, mapped by the directory path. Can be when the fast skip is disabled. /// The batch of discovered files that is written to the staging results when it reaches the batch size. /// The batch of directory scan fingerprints that is written to the storage medium when it reaches the batch size. @@ -204,6 +216,7 @@ internal sealed class MusicFileSystemDiscoveryJob : MediaLibraryScanJob, IMusicF IFileProviderService fileProviderService, IDirectoryProviderService directoryProviderService, bool shouldSkipUnchangedDirectories, + bool shouldParallelizeReads, Dictionary? fingerprintsByPath, List stagingBatch, List fingerprintBatch, @@ -258,40 +271,24 @@ internal sealed class MusicFileSystemDiscoveryJob : MediaLibraryScanJob, IMusicF Result> getFilesResult = fileProviderService.GetFilePaths(currentDirectory, true); if (getFilesResult.IsSuccess) { - foreach (FileSystemPathId filePath in getFilesResult.Value) + if (shouldParallelizeReads) + await StageFilesInParallelAsync(getFilesResult.Value, fileProviderService, stagingBatch, stagingResultsRepository, cancellationToken).ConfigureAwait(false); + else { - cancellationToken.ThrowIfCancellationRequested(); - if (!s_audioExtensions.Contains(Path.GetExtension(filePath.Path))) - continue; - - long size = 0; - Result getSizeResult = fileProviderService.GetSize(filePath); - if (getSizeResult.IsSuccess && getSizeResult.Value.HasValue) - size = getSizeResult.Value.Value; - - long ticks = 0; - Result> getFileLastWriteTimeResult = fileProviderService.GetLastWriteTime(filePath); - if (getFileLastWriteTimeResult.IsSuccess && getFileLastWriteTimeResult.Value.HasValue) - ticks = getFileLastWriteTimeResult.Value.Value.Ticks; - - stagingBatch.Add(new LibraryScanStagingResultsEntity() + foreach (FileSystemPathId filePath in getFilesResult.Value) { - Id = Guid.NewGuid(), - LibraryScanId = ScanId.Value, - Path = filePath.Path, - Size = size, - Ticks = ticks, - ContentHash = 0, - PreviousContentHash = 0, - NeedsRehash = true, - IsNew = true - }); - if (stagingBatch.Count >= STAGING_BATCH_SIZE) - { - Result insertBatchResult = await stagingResultsRepository.InsertRangeAsync(stagingBatch, cancellationToken).ConfigureAwait(false); - if (insertBatchResult.IsFailure) - throw new InvalidOperationException(insertBatchResult.FirstError.Description); - stagingBatch.Clear(); + cancellationToken.ThrowIfCancellationRequested(); + if (!s_audioExtensions.Contains(Path.GetExtension(filePath.Path))) + continue; + + stagingBatch.Add(CreateStagingResult(filePath, fileProviderService)); + if (stagingBatch.Count >= STAGING_BATCH_SIZE) + { + Result insertBatchResult = await stagingResultsRepository.InsertRangeAsync(stagingBatch, cancellationToken).ConfigureAwait(false); + if (insertBatchResult.IsFailure) + throw new InvalidOperationException(insertBatchResult.FirstError.Description); + stagingBatch.Clear(); + } } } } @@ -309,6 +306,102 @@ internal sealed class MusicFileSystemDiscoveryJob : MediaLibraryScanJob, IMusicF } } + /// + /// Reads the metadata of in parallel and writes the discovered music files in batches to the staging results. + /// + /// The file paths of the current directory. + /// The service used to read the metadata of a file. + /// The batch of discovered files that is written to the staging results when it reaches the batch size. + /// The repository used to write the discovered files to the staging results. + /// Cancellation token that can be used to stop the execution. + private async Task StageFilesInParallelAsync( + IEnumerable filePaths, + IFileProviderService fileProviderService, + List stagingBatch, + ILibraryScanStagingResultsRepository stagingResultsRepository, + CancellationToken cancellationToken) + { + List filesToProcess = [.. filePaths.Where(filePath => s_audioExtensions.Contains(Path.GetExtension(filePath.Path)))]; + LibraryScanStagingResultsEntity?[] discoveredFiles = new LibraryScanStagingResultsEntity?[filesToProcess.Count]; + ParallelOptions parallelOptions = new() + { + CancellationToken = cancellationToken, + MaxDegreeOfParallelism = Environment.ProcessorCount + }; + + try + { + Parallel.For(0, filesToProcess.Count, parallelOptions, index => + { + try + { + discoveredFiles[index] = CreateStagingResult(filesToProcess[index], fileProviderService); + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) + { + // A file might become inaccessible between enumeration and processing, so it is skipped. + _logger.LogWarning(ex, "Failed to read the metadata of the music file '{Path}', so it is skipped for this scan.", filesToProcess[index].Path); + } + }); + } + catch (AggregateException aggregateException) + { + // Parallel.For wraps the exceptions thrown by its body, so the real cause is rethrown here, to keep the reported scan failure meaningful. + AggregateException flattenedException = aggregateException.Flatten(); + if (flattenedException.InnerExceptions.Count == 1) + ExceptionDispatchInfo.Capture(flattenedException.InnerExceptions[0]).Throw(); + throw new AggregateException(string.Join("; ", flattenedException.InnerExceptions.Select(exception => exception.Message)), flattenedException.InnerExceptions); + } + + // The repository is not thread-safe, so the discovered files are written sequentially, in bounded batches. + foreach (LibraryScanStagingResultsEntity? discoveredFile in discoveredFiles) + { + cancellationToken.ThrowIfCancellationRequested(); + if (discoveredFile is null) + continue; + stagingBatch.Add(discoveredFile); + if (stagingBatch.Count >= STAGING_BATCH_SIZE) + { + Result insertBatchResult = await stagingResultsRepository.InsertRangeAsync(stagingBatch, cancellationToken).ConfigureAwait(false); + if (insertBatchResult.IsFailure) + throw new InvalidOperationException(insertBatchResult.FirstError.Description); + stagingBatch.Clear(); + } + } + } + + /// + /// Creates a staging result entity from a discovered music file. + /// + /// The discovered music file. + /// The service used to read the metadata of a file. + /// The staging result entity of the file. + private LibraryScanStagingResultsEntity CreateStagingResult(FileSystemPathId filePath, IFileProviderService fileProviderService) + { + long size = 0; + Result getSizeResult = fileProviderService.GetSize(filePath); + if (getSizeResult.IsSuccess && getSizeResult.Value.HasValue) + size = getSizeResult.Value.Value; + + long ticks = 0; + Result> getFileLastWriteTimeResult = fileProviderService.GetLastWriteTime(filePath); + if (getFileLastWriteTimeResult.IsSuccess && getFileLastWriteTimeResult.Value.HasValue) + ticks = getFileLastWriteTimeResult.Value.Value.Ticks; + + return new LibraryScanStagingResultsEntity() + { + Id = Guid.NewGuid(), + LibraryScanId = ScanId.Value, + Path = filePath.Path, + Size = size, + Ticks = ticks, + ContentHash = 0, + PreviousContentHash = 0, + NeedsRehash = true, + IsNew = true + }; + } + /// /// Publishes a job progress update. /// diff --git a/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/Common/MediaLibraryScanHashJob.cs b/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/Common/MediaLibraryScanHashJob.cs index 8f334a8c..41eff734 100644 --- a/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/Common/MediaLibraryScanHashJob.cs +++ b/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/Common/MediaLibraryScanHashJob.cs @@ -1,19 +1,19 @@ #region ========================================================================= USING ===================================================================================== -using Lumina.Domain.Common.Primitives; -using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary; +using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Application.Common.DataAccess.UoW; +using Lumina.Application.Common.Infrastructure.Models.DTO.MediaLibraryScanJobPayloads; using Lumina.Application.Common.Infrastructure.Security; -using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary; using Lumina.Domain.Common.Events; +using Lumina.Domain.Common.Primitives; 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.SharedKernel.Common.Enums.MediaLibrary; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Lumina.Application.Common.Infrastructure.Models.DTO.MediaLibraryScanJobPayloads; #endregion namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common; @@ -23,7 +23,7 @@ namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Commo /// internal sealed class MediaLibraryScanHashJob : MediaLibraryScanJob, IMediaLibraryScanHashJob { - private const int HASHING_PAGE_SIZE = 1000; // the number of files that are hashed and written back in a single batch, keeping the peak memory bounded regardless of the library size + private const int HASHING_PAGE_SIZE = 1000; // The number of files that are hashed and written back in a single batch, keeping the peak memory bounded regardless of the library size. private readonly IServiceScopeFactory _serviceScopeFactory; /// @@ -49,9 +49,9 @@ internal sealed class MediaLibraryScanHashJob : MediaLibraryScanJob, IMediaLibra { try { - // increment the number of parents that finished their execution and called this job (beware race conditions, jobs run in parallel) + // Increment the number of parents that finished their execution and called this job (beware race conditions, jobs run in parallel). int parentsCompleted = Interlocked.Increment(ref parentsPayloadsExecuted); - // 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 || parentsCompleted == 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 @@ -59,7 +59,7 @@ internal sealed class MediaLibraryScanHashJob : MediaLibraryScanJob, IMediaLibra await Task.Run(async () => { Status = LibraryScanJobStatus.Running; - // see docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0001.md for details: + // See docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0001.md for details: await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope(); IUnitOfWork unitOfWork = asyncServiceScope.ServiceProvider.GetService()!; IDomainEventPublisher domainEventPublisher = asyncServiceScope.ServiceProvider.GetService()!; @@ -74,7 +74,22 @@ internal sealed class MediaLibraryScanHashJob : MediaLibraryScanJob, IMediaLibra throw new InvalidOperationException(getFilesToHashCountResult.FirstError.Description); int totalFilesToHash = getFilesToHashCountResult.Value; - // set the initial progress of the scan job + // Get the library only when there are files to hash, and only the scalar values needed to know whether its content is stored on a solid state drive,. + // in which case the file reads run in parallel. + bool shouldParallelizeReads = false; + if (totalFilesToHash > 0) + { + Result getLibraryResult = await unitOfWork.LibraryRepository.GetByIdAsync( + LibraryId.Value, + shouldIncludeNavigationProperties: false, + shouldTrackEntities: false, + cancellationToken: cancellationToken).ConfigureAwait(false); + if (getLibraryResult.IsFailure || getLibraryResult.Value is null) + throw new InvalidOperationException(getLibraryResult.IsFailure ? getLibraryResult.FirstError.Description : "The media library was not found."); + shouldParallelizeReads = getLibraryResult.Value.IsContentOnSsd; + } + + // Set the initial progress of the scan job. Result publishJobProgressResult = await PublishJobProgressAsync(domainEventPublisher, compositeKey, 0, totalFilesToHash, cancellationToken).ConfigureAwait(false); if (publishJobProgressResult.IsFailure) throw new InvalidOperationException(publishJobProgressResult.FirstError.Description); @@ -84,7 +99,7 @@ internal sealed class MediaLibraryScanHashJob : MediaLibraryScanJob, IMediaLibra int processedFilesCount = 0; string? lastPath = null; - // process the files that need hashing in pages, keeping the peak memory bounded regardless of the library size + // Process the files that need hashing in pages, keeping the peak memory bounded regardless of the library size. while (true) { cancellationToken.ThrowIfCancellationRequested(); @@ -96,14 +111,14 @@ internal sealed class MediaLibraryScanHashJob : MediaLibraryScanJob, IMediaLibra if (filesToHashPage.Count == 0) break; - // hash the files of the current page in parallel, invoking the progress callback before each file - List hashedFiles = await fileHashService.HashFilesAsync(filesToHashPage, async () => + // Hash the files of the current page in parallel, invoking the progress callback before each file. + List hashedFiles = await fileHashService.HashFilesAsync(filesToHashPage, shouldParallelizeReads, async () => { - // check if enough time has passed since last update + // Check if enough time has passed since last update. DateTime now = DateTime.UtcNow; if ((now - lastUpdateTime).TotalMilliseconds >= minUpdateIntervalMs) { - // increment the number of processed elements progress + // Increment the number of processed elements progress. publishJobProgressResult = await PublishJobProgressAsync(domainEventPublisher, compositeKey, Interlocked.Increment(ref processedFilesCount), totalFilesToHash, cancellationToken).ConfigureAwait(false); if (publishJobProgressResult.IsFailure) throw new InvalidOperationException(publishJobProgressResult.FirstError.Description); @@ -111,7 +126,7 @@ internal sealed class MediaLibraryScanHashJob : MediaLibraryScanJob, IMediaLibra } }, cancellationToken).ConfigureAwait(false); - // write the computed hashes back to the staging results + // Write the computed hashes back to the staging results. Result updateHashesResult = await unitOfWork.LibraryScanStagingResultsRepository.UpdateFileHashesAsync(ScanId.Value, hashedFiles, cancellationToken).ConfigureAwait(false); if (updateHashesResult.IsFailure) throw new InvalidOperationException(updateHashesResult.FirstError.Description); @@ -119,11 +134,11 @@ internal sealed class MediaLibraryScanHashJob : MediaLibraryScanJob, IMediaLibra lastPath = filesToHashPage[^1].Path; } - // this job finished, increment the number of processed jobs progress + // This job finished, increment the number of processed jobs progress. await domainEventPublisher.PublishAsync(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false); Status = LibraryScanJobStatus.Completed; - // call each linked child with the obtained payload + // Call each linked child with the obtained payload. foreach (IMediaLibraryScanJob child in Children) await child.ExecuteAsync(id, input, cancellationToken).ConfigureAwait(false); }, cancellationToken).ConfigureAwait(false); diff --git a/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJob.cs b/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJob.cs index 05a909de..5bd14638 100644 --- a/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJob.cs +++ b/src/Lumina.Infrastructure/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJob.cs @@ -1,25 +1,26 @@ #region ========================================================================= USING ===================================================================================== -using Lumina.Domain.Common.Primitives; 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.SharedKernel.Common.Enums.MediaLibrary; using Lumina.Domain.Common.Events; +using Lumina.Domain.Common.Primitives; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects; 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 Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary; using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; #endregion @@ -31,7 +32,7 @@ namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Writt /// internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksFileSystemDiscoveryJob { - private const int STAGING_BATCH_SIZE = 1000; // the number of discovered files that are written to the staging results in a single batch, keeping the peak memory bounded regardless of the library size + private const int STAGING_BATCH_SIZE = 1000; // The number of discovered files that are written to the staging results in a single batch, keeping the peak memory bounded regardless of the library size. private static readonly HashSet s_bookExtensions = new( [ ".pdf", ".epub", ".mobi", ".azw", ".azw3", @@ -42,11 +43,12 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF ); private static readonly EnumerationOptions s_enumerationOptions = new() { - AttributesToSkip = FileAttributes.None, // hidden files and directories are included in the discovery + AttributesToSkip = FileAttributes.None, // Hidden files and directories are included in the discovery. IgnoreInaccessible = true, RecurseSubdirectories = false }; private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. @@ -55,9 +57,11 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF /// Injected factory for creating scopes in which services are requested. /// See docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0001.md for details. /// - public BooksFileSystemDiscoveryJob(IServiceScopeFactory serviceScopeFactory) + /// Injected logger for the media library scan job. + public BooksFileSystemDiscoveryJob(IServiceScopeFactory serviceScopeFactory, ILogger logger) { _serviceScopeFactory = serviceScopeFactory; + _logger = logger; } /// @@ -71,34 +75,34 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF { try { - // increment the number of parents that finished their execution and called this job (beware race conditions, jobs run in parallel) + // Increment the number of parents that finished their execution and called this job (beware race conditions, jobs run in parallel). int parentsCompleted = Interlocked.Increment(ref parentsPayloadsExecuted); // only execute this job's payload when it has no parents, or when all the parents finished their execution if (Parents.Count == 0 || parentsCompleted == 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 + // 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; - // see docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0001.md for details: + // See docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0001.md for details: await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope(); IUnitOfWork unitOfWork = asyncServiceScope.ServiceProvider.GetService()!; IDomainEventPublisher domainEventPublisher = asyncServiceScope.ServiceProvider.GetService()!; MediaLibraryScanCompositeId compositeKey = MediaLibraryScanCompositeId.Create(ScanId, UserId); - // get the library from the repository + // Get the library from the repository. Result getLibraryResult = await unitOfWork.LibraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken: cancellationToken).ConfigureAwait(false); if (getLibraryResult.IsFailure || getLibraryResult.Value is null) throw new InvalidOperationException(getLibraryResult.IsFailure ? getLibraryResult.FirstError.Description : "The media library was not found."); - // convert it to a domain object + // Convert it to a domain object. Result domainLibraryResult = getLibraryResult.Value.ToDomainEntity(); if (domainLibraryResult.IsFailure) throw new InvalidOperationException(domainLibraryResult.FirstError.Description); - // when the fast skip is enabled, load the directory scan fingerprints of the library, used to skip the directories that have not changed since the last scan + // When the fast skip is enabled, load the directory scan fingerprints of the library, used to skip the directories that have not changed since the last scan. Dictionary? fingerprintsByPath = null; if (domainLibraryResult.Value.ShouldSkipUnchangedDirectoriesDuringScan) { @@ -108,7 +112,7 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF fingerprintsByPath = getFingerprintsResult.Value; } - // set the initial progress of the scan job + // Set the initial progress of the scan job. Result publishJobProgressResult = await PublishJobProgressAsync(domainEventPublisher, compositeKey, 0, domainLibraryResult.Value.ContentLocations.Count, cancellationToken).ConfigureAwait(false); if (publishJobProgressResult.IsFailure) throw new InvalidOperationException(publishJobProgressResult.FirstError.Description); @@ -120,7 +124,12 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF List stagingBatch = []; List fingerprintBatch = []; - // get the files for each of the media library content locations + // When the library content is stored on a solid state drive, the file system reads of the scan run in parallel. + bool shouldParallelizeReads = domainLibraryResult.Value.IsContentOnSsd; + if (shouldParallelizeReads) + _logger.LogDebug("The content of the media library with Id '{LibraryId}' is stored on a solid state drive, so its file system reads will run in parallel.", LibraryId.Value); + + // Get the files for each of the media library content locations. foreach (FileSystemPathId contentLocation in domainLibraryResult.Value.ContentLocations) { cancellationToken.ThrowIfCancellationRequested(); @@ -128,6 +137,7 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF await DiscoverContentLocationAsync( contentLocation.Path, fingerprintsByPath is not null, + shouldParallelizeReads, fingerprintsByPath, stagingBatch, fingerprintBatch, @@ -136,7 +146,7 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF cancellationToken).ConfigureAwait(false); processedContentLocations++; - // increment the number of processed elements progress in a high-frequency counter with low overhead check + // Increment the number of processed elements progress in a high-frequency counter with low overhead check. DateTime now = DateTime.UtcNow; if (now - lastHeartbeat >= heartbeatInterval) { @@ -148,7 +158,7 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF } } - // flush any remaining discovered files and directory scan fingerprints that did not reach the batch size + // Flush any remaining discovered files and directory scan fingerprints that did not reach the batch size. if (stagingBatch.Count > 0) { Result insertResult = await unitOfWork.LibraryScanStagingResultsRepository.InsertRangeAsync(stagingBatch, cancellationToken).ConfigureAwait(false); @@ -162,11 +172,11 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF throw new InvalidOperationException(upsertResult.FirstError.Description); } - // this job finished, increment the number of processed jobs progress + // This job finished, increment the number of processed jobs progress. await domainEventPublisher.PublishAsync(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false); Status = LibraryScanJobStatus.Completed; - // call each linked child with the obtained payload + // Call each linked child with the obtained payload. foreach (IMediaLibraryScanJob child in Children) await child.ExecuteAsync(id, input, cancellationToken).ConfigureAwait(false); }, cancellationToken).ConfigureAwait(false); @@ -189,6 +199,7 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF /// /// The path of the root directory from which to start collecting files. /// Whether to skip the directories whose last write time has not changed since the last scan, or not. + /// Whether the file system reads should run in parallel, which benefits solid state drives. /// The directory scan fingerprints of the library, mapped by the directory path. Can be when the fast skip is disabled. /// The batch of discovered files that is written to the staging results when it reaches the batch size. /// The batch of directory scan fingerprints that is written to the storage medium when it reaches the batch size. @@ -202,6 +213,7 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF private async Task DiscoverContentLocationAsync( string rootDirectoryPath, bool shouldSkipUnchangedDirectories, + bool shouldParallelizeReads, Dictionary? fingerprintsByPath, List stagingBatch, List fingerprintBatch, @@ -212,14 +224,13 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF Queue directoryQueue = new(); directoryQueue.Enqueue(new DirectoryInfo(rootDirectoryPath)); - // use a breadth-first traversal iterative approach, instead of recursion, which is heavier on call frames and memory - // and could result in stack overflow on deeply nested directories + // Use a breadth-first traversal iterative approach, instead of recursion, which is heavier on call frames and memory and could result in stack overflow on deeply nested directories. while (directoryQueue.Count > 0) { cancellationToken.ThrowIfCancellationRequested(); DirectoryInfo currentDirectory = directoryQueue.Dequeue(); - // when the fast skip is enabled, skip the whole subtree of a directory whose last write time has not changed since the last scan + // When the fast skip is enabled, skip the whole subtree of a directory whose last write time has not changed since the last scan. if (shouldSkipUnchangedDirectories) { DateTime currentLastWriteTimeUtc = currentDirectory.LastWriteTimeUtc; @@ -235,7 +246,7 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF Path = currentDirectory.FullName, LastWriteTimeUtc = currentLastWriteTimeUtc }); - // flush the collected directory scan fingerprints in bounded batches, so that the memory usage stays proportional to the batch size, no matter how many directories the library has + // Flush the collected directory scan fingerprints in bounded batches, so that the memory usage stays proportional to the batch size, no matter how many directories the library has. if (fingerprintBatch.Count >= STAGING_BATCH_SIZE) { Result upsertFingerprintsResult = await directoryScanFingerprintRepository.UpsertRangeAsync(fingerprintBatch, cancellationToken).ConfigureAwait(false); @@ -245,62 +256,56 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF } } - // process the files of the current directory + // Process the files of the current directory. IEnumerable? files = null; try { files = currentDirectory.EnumerateFiles("*", s_enumerationOptions) .Where(file => s_bookExtensions.Contains(file.Extension)); } - catch (IOException ex) + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { - Debug.WriteLine(ex.Message); + _logger.LogWarning(ex, "Failed to enumerate the files of the directory '{DirectoryPath}', so its files are skipped for this scan.", currentDirectory.FullName); } if (files is not null) { try { - foreach (FileInfo file in files) + if (shouldParallelizeReads) + await StageFilesInParallelAsync(files, stagingBatch, stagingResultsRepository, cancellationToken).ConfigureAwait(false); + else { - cancellationToken.ThrowIfCancellationRequested(); - stagingBatch.Add(new LibraryScanStagingResultsEntity() + foreach (FileInfo file in files) { - Id = Guid.NewGuid(), - LibraryScanId = ScanId.Value, - Path = file.FullName, - Size = file.Length, - Ticks = file.LastWriteTimeUtc.Ticks, - ContentHash = 0, - PreviousContentHash = 0, - NeedsRehash = true, - IsNew = true - }); - if (stagingBatch.Count >= STAGING_BATCH_SIZE) - { - Result insertBatchResult = await stagingResultsRepository.InsertRangeAsync(stagingBatch, cancellationToken).ConfigureAwait(false); - if (insertBatchResult.IsFailure) - throw new InvalidOperationException(insertBatchResult.FirstError.Description); - stagingBatch.Clear(); + cancellationToken.ThrowIfCancellationRequested(); + stagingBatch.Add(CreateStagingResult(file)); + if (stagingBatch.Count >= STAGING_BATCH_SIZE) + { + Result insertBatchResult = await stagingResultsRepository.InsertRangeAsync(stagingBatch, cancellationToken).ConfigureAwait(false); + if (insertBatchResult.IsFailure) + throw new InvalidOperationException(insertBatchResult.FirstError.Description); + stagingBatch.Clear(); + } } } } - catch (IOException ex) + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { - // a file might become inaccessible between enumeration and processing, so the remaining files of the directory are skipped - Debug.WriteLine(ex.Message); + // A file might become inaccessible between enumeration and processing, so the remaining files of the directory are skipped. + _logger.LogWarning(ex, "Failed to read the metadata of the files of the directory '{DirectoryPath}', so the remaining files of the directory are skipped for this scan.", currentDirectory.FullName); } } - // process the subdirectories - each new subdirectory is added to the same stack queue, for later processing + // Process the subdirectories - each new subdirectory is added to the same stack queue, for later processing. IEnumerable? subdirectories = null; try { subdirectories = currentDirectory.EnumerateDirectories("*", s_enumerationOptions); } - catch (IOException ex) + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { - Debug.WriteLine(ex.Message); + _logger.LogWarning(ex, "Failed to enumerate the subdirectories of the directory '{DirectoryPath}', so its subtree is skipped for this scan.", currentDirectory.FullName); } if (subdirectories is not null) @@ -313,14 +318,93 @@ internal sealed class BooksFileSystemDiscoveryJob : MediaLibraryScanJob, IBooksF directoryQueue.Enqueue(subdirectory); } } - catch (IOException ex) + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { - Debug.WriteLine(ex.Message); + _logger.LogWarning(ex, "Failed to process the subdirectories of the directory '{DirectoryPath}', so the remaining subdirectories are skipped for this scan.", currentDirectory.FullName); } } } } + /// + /// Reads the metadata of in parallel and writes the discovered files in batches to the staging results. + /// + /// The files of the current directory. + /// The batch of discovered files that is written to the staging results when it reaches the batch size. + /// The repository used to write the discovered files to the staging results. + /// Cancellation token that can be used to stop the execution. + internal async Task StageFilesInParallelAsync(IEnumerable files, List stagingBatch, ILibraryScanStagingResultsRepository stagingResultsRepository, CancellationToken cancellationToken) + { + List filesToProcess = [.. files]; + LibraryScanStagingResultsEntity?[] discoveredFiles = new LibraryScanStagingResultsEntity?[filesToProcess.Count]; + ParallelOptions parallelOptions = new() + { + CancellationToken = cancellationToken, + MaxDegreeOfParallelism = Environment.ProcessorCount + }; + + try + { + Parallel.For(0, filesToProcess.Count, parallelOptions, index => + { + try + { + discoveredFiles[index] = CreateStagingResult(filesToProcess[index]); + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) + { + // A file might become inaccessible between enumeration and processing, so it is skipped. + _logger.LogWarning(ex, "Failed to read the metadata of the book file '{Path}', so it is skipped for this scan.", filesToProcess[index].FullName); + } + }); + } + catch (AggregateException aggregateException) + { + // Parallel.For wraps the exceptions thrown by its body, so the real cause is rethrown here, to keep the reported scan failure meaningful. + AggregateException flattenedException = aggregateException.Flatten(); + if (flattenedException.InnerExceptions.Count == 1) + ExceptionDispatchInfo.Capture(flattenedException.InnerExceptions[0]).Throw(); + throw new AggregateException(string.Join("; ", flattenedException.InnerExceptions.Select(exception => exception.Message)), flattenedException.InnerExceptions); + } + + // The repository is not thread-safe, so the discovered files are written sequentially, in bounded batches. + foreach (LibraryScanStagingResultsEntity? discoveredFile in discoveredFiles) + { + cancellationToken.ThrowIfCancellationRequested(); + if (discoveredFile is null) + continue; + stagingBatch.Add(discoveredFile); + if (stagingBatch.Count >= STAGING_BATCH_SIZE) + { + Result insertBatchResult = await stagingResultsRepository.InsertRangeAsync(stagingBatch, cancellationToken).ConfigureAwait(false); + if (insertBatchResult.IsFailure) + throw new InvalidOperationException(insertBatchResult.FirstError.Description); + stagingBatch.Clear(); + } + } + } + + /// + /// Creates a staging result entity from a discovered file. + /// + /// The discovered file. + /// The staging result entity of the file. + private LibraryScanStagingResultsEntity CreateStagingResult(FileInfo file) + { + return new LibraryScanStagingResultsEntity() + { + Id = Guid.NewGuid(), + LibraryScanId = ScanId.Value, + Path = file.FullName, + Size = file.Length, + Ticks = file.LastWriteTimeUtc.Ticks, + ContentHash = 0, + PreviousContentHash = 0, + NeedsRehash = true, + IsNew = true + }; + } + /// /// Publishes a job progress update. /// diff --git a/src/Lumina.Infrastructure/Core/Security/FileHashService.cs b/src/Lumina.Infrastructure/Core/Security/FileHashService.cs index 6a4aba9f..f5875fdf 100644 --- a/src/Lumina.Infrastructure/Core/Security/FileHashService.cs +++ b/src/Lumina.Infrastructure/Core/Security/FileHashService.cs @@ -27,36 +27,37 @@ internal class FileHashService : IFileHashService /// Hashes by sampling chunks from them. /// /// The collection of files to hash. + /// Whether the files should be read in parallel. Parallel reads benefit solid state drives, while mechanical hard drives are faster with sequential reads. /// Callback to invoke during processing of elements. /// Cancellation token that can be used to stop the execution. /// A collection of the hashed files, along with their hashes. - public async Task> HashFilesAsync(IReadOnlyCollection inputFiles, Func callback, CancellationToken cancellationToken) + public async Task> HashFilesAsync(IReadOnlyCollection inputFiles, bool shouldParallelizeReads, Func callback, CancellationToken cancellationToken) { List outputFiles = []; object listLock = new(); - // make use of all available processors + // Solid state drives benefit from reading multiple files at once, while mechanical hard drives are faster with sequential reads because of their seek time. ParallelOptions parallelOptions = new() { CancellationToken = cancellationToken, - MaxDegreeOfParallelism = Environment.ProcessorCount // TODO: make this configurable, such that parallelism can be turned off for mechanical hard drives + MaxDegreeOfParallelism = shouldParallelizeReads ? Environment.ProcessorCount : 1 }; await Parallel.ForEachAsync(inputFiles, parallelOptions, async (file, cancellationToken) => { cancellationToken.ThrowIfCancellationRequested(); try { - // invoke the method that triggers progress reporting + // Invoke the method that triggers progress reporting. await callback().ConfigureAwait(false); ushort bufferSize = (ushort)Math.Min(DEFAULT_BUFFER_SIZE, file.Size); - // get the file hash and check if it differs from the one stored on previous scan + // Get the file hash and check if it differs from the one stored on previous scan. ulong currentHash = file.Size == 0 - ? s_emptyFileHash // precomputed constant: XxHash64 hash of zero-length input + ? s_emptyFileHash // Precomputed constant: XxHash64 hash of zero-length input. : ComputeFileHash(file.Path, file.Size, bufferSize); - // the decision of whether a file changed is already made before hashing, so all files that reach this point get their hash stored + // The decision of whether a file changed is already made before hashing, so all files that reach this point get their hash stored. lock (listLock) outputFiles.Add(file with { CurrentHash = currentHash }); } @@ -78,7 +79,7 @@ internal class FileHashService : IFileHashService { long fileSize = new FileInfo(filePath).Length; if (fileSize == 0) - return s_emptyFileHash; // precomputed constant: XxHash64 hash of zero-length input + return s_emptyFileHash; // Precomputed constant: XxHash64 hash of zero-length input. ushort bufferSize = (ushort)Math.Min(DEFAULT_BUFFER_SIZE, fileSize); return ComputeFileHash(filePath, fileSize, bufferSize); @@ -92,46 +93,46 @@ internal class FileHashService : IFileHashService /// Sample window size (automatically clamped to file size). private static unsafe ulong ComputeFileHash(string filePath, long fileSize, ushort bufferSize) { - // create a memory-mapped file for efficient access to large files + // Create a memory-mapped file for efficient access to large files. using MemoryMappedFile memoryMappedFile = MemoryMappedFile.CreateFromFile(filePath, FileMode.Open, null, 0, MemoryMappedFileAccess.Read); - // create a view accessor to read from the memory-mapped file + // Create a view accessor to read from the memory-mapped file. using MemoryMappedViewAccessor memoryMappedViewAccessor = memoryMappedFile.CreateViewAccessor(0, fileSize, MemoryMappedFileAccess.Read); byte* memoryPointer = null; try { - // get a direct pointer to the memory-mapped file, for faster access + // Get a direct pointer to the memory-mapped file, for faster access. memoryMappedViewAccessor.SafeMemoryMappedViewHandle.AcquirePointer(ref memoryPointer); - // get the thread-local hasher and reset it before use; resetting at entry (rather than at exit) ensures - // the hasher is always in a clean state even if a previous call on this thread threw mid-computation + // Get the thread-local hasher and reset it before use; resetting at entry (rather than at exit) ensures + // the hasher is always in a clean state even if a previous call on this thread threw mid-computation. XxHash64 hasher = s_threadLocalHasher.Value!; hasher.Reset(); - // allocate hash result buffer on the stack, to avoid heap allocation + // Allocate hash result buffer on the stack, to avoid heap allocation. Span hashSpan = stackalloc byte[sizeof(ulong)]; - // process only predefined sampled segments of the file, instead of the entire file + // Process only predefined sampled segments of the file, instead of the entire file. foreach (long offset in GetByteBufferSampleOffsets(fileSize, bufferSize)) { - // calculate how many bytes to read (handle edge case at end of file, or when the file size is smaller than the buffer) + // Calculate how many bytes to read (handle edge case at end of file, or when the file size is smaller than the buffer). ushort readSize = (ushort)Math.Min(bufferSize, fileSize - offset); - // create a span directly over the memory-mapped region + // Create a span directly over the memory-mapped region. ReadOnlySpan dataSpan = new(memoryPointer + offset, readSize); - // update the hash with this chunk of data + // Update the hash with this chunk of data. hasher.Append(dataSpan); } - // get the final hash value + // Get the final hash value. if (!hasher.TryGetCurrentHash(hashSpan, out int bytesWritten) || bytesWritten != sizeof(ulong)) throw new InvalidOperationException("Hash computation failed"); - // convert the hash byte span to a long, and return it + // Convert the hash byte span to a long, and return it. return BitConverter.ToUInt64(hashSpan); } finally { - if (memoryPointer is not null) // always release the pointer, to prevent memory leaks + if (memoryPointer is not null) // Always release the pointer, to prevent memory leaks. memoryMappedViewAccessor.SafeMemoryMappedViewHandle.ReleasePointer(); } } @@ -144,20 +145,20 @@ internal class FileHashService : IFileHashService /// An enumerable of byte offsets to sample from the file. private static IEnumerable GetByteBufferSampleOffsets(long fileSize, ushort bufferSize) { - // for small files, just read from the beginning + // For small files, just read from the beginning. if (fileSize <= bufferSize * SAMPLE_COUNT) { yield return 0; yield break; } - // for larger files, sample at strategic points: - yield return 0; // beginning of the file - yield return fileSize / 4; // quarter of the file - yield return fileSize / 2; // half of the file - yield return 3 * fileSize / 4; // three quarters of the file - yield return Math.Max(0, fileSize - bufferSize); // end of the file (ensure we don't go past the end) + // For larger files, sample at strategic points: + yield return 0; // Beginning of the file. + yield return fileSize / 4; // Quarter of the file. + yield return fileSize / 2; // Half of the file. + yield return 3 * fileSize / 4; // Three quarters of the file. + yield return Math.Max(0, fileSize - bufferSize); // End of the file (ensure we don't go past the end). - // additional evenly spaced samples, if needed + // Additional evenly spaced samples, if needed. long interval = fileSize / (SAMPLE_COUNT + 1); for (int i = 1; i <= SAMPLE_COUNT - 4; i++) yield return interval * i; diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs index c8635a96..a2e8a6f0 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs @@ -37,6 +37,7 @@ public class AddLibraryEndpointSummary : Summary r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional."); RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional."); RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional."); + RequestParam(r => r.IsContentOnSsd, "Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. Optional."); RequestParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items should be tracked, or not. Optional, the default of the library type is used when absent."); RequestParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the default of the library type is used when absent."); RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent."); @@ -66,6 +68,7 @@ public class AddLibraryEndpointSummary : Summary(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not."); ResponseParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not."); ResponseParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not."); + ResponseParam(r => r.IsContentOnSsd, "Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel."); ResponseParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked."); ResponseParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled."); ResponseParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk."); @@ -85,6 +88,7 @@ public class AddLibraryEndpointSummary : Summary(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not."); ResponseParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not."); ResponseParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not."); + ResponseParam(r => r.IsContentOnSsd, "Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel."); ResponseParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked."); ResponseParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled."); ResponseParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk."); @@ -53,6 +54,7 @@ public class GetEnabledLibrariesEndpointSummary : Summary(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not."); ResponseParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not."); ResponseParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not."); + ResponseParam(r => r.IsContentOnSsd, "Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel."); ResponseParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked."); ResponseParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled."); ResponseParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk."); @@ -53,6 +54,7 @@ public class GetLibrariesEndpointSummary : Summary(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not."); ResponseParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not."); ResponseParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not."); + ResponseParam(r => r.IsContentOnSsd, "Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel."); ResponseParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked."); ResponseParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled."); ResponseParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk."); @@ -59,6 +60,7 @@ public class GetLibraryEndpointSummary : Summary r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional."); RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional."); RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional."); + RequestParam(r => r.IsContentOnSsd, "Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. Optional."); RequestParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items should be tracked, or not. Optional, the stored value is kept when absent."); RequestParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the stored value is kept when absent."); RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent."); @@ -70,6 +72,7 @@ public class UpdateLibraryEndpointSummary : Summary(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not."); ResponseParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not."); ResponseParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not."); + ResponseParam(r => r.IsContentOnSsd, "Whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel."); ResponseParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items is tracked."); ResponseParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed, when progress tracking is enabled."); ResponseParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk."); @@ -89,6 +92,7 @@ public class UpdateLibraryEndpointSummary : Summary public bool ShouldSkipUnchangedDirectoriesDuringScan { get; set; } = false; + /// + /// Gets or sets whether the content of this media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. + /// + public bool IsContentOnSsd { get; set; } = false; + /// /// Gets or sets whether the consumption progress of the media library items is tracked, or not. When absent, the default of the library type is used on create, and the stored value is kept on update. /// diff --git a/src/Lumina.Presentation.Web/Core/Endpoints/Library/Management/SaveLibrary/SaveLibraryEndpointSummary.cs b/src/Lumina.Presentation.Web/Core/Endpoints/Library/Management/SaveLibrary/SaveLibraryEndpointSummary.cs index 73bc9ef4..338d22c4 100644 --- a/src/Lumina.Presentation.Web/Core/Endpoints/Library/Management/SaveLibrary/SaveLibraryEndpointSummary.cs +++ b/src/Lumina.Presentation.Web/Core/Endpoints/Library/Management/SaveLibrary/SaveLibraryEndpointSummary.cs @@ -31,6 +31,10 @@ public class SaveLibraryEndpointSummary : Summary r.CanDownloadMetadataFromWeb, "Whether the metadata of the media library items should be downloaded from the web, or not. Optional."); RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether the downloaded metadata should be copied into the media library content locations, or not. Optional."); RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether the directories whose contents have not changed since the last scan should be skipped during the scan, or not. Optional."); + RequestParam(r => r.IsContentOnSsd, "Whether the content of the media library is stored on a solid state drive, in which case the file discovery and content hashing stages read the files in parallel. Optional."); + RequestParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items should be tracked, or not. Optional, the default of the library type is used on create, and the stored value is kept on update."); + RequestParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the default of the library type is used on create, and the stored value is kept on update."); + RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent."); ExampleRequest = new LibraryDto(); diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/ChangePassword.Designer.cs b/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/ChangePassword.Designer.cs deleted file mode 100644 index 929e4c25..00000000 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/ChangePassword.Designer.cs +++ /dev/null @@ -1,135 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Lumina.Presentation.Web.Core.Resources.Views.Auth { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class ChangePassword { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal ChangePassword() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lumina.Presentation.Web.Core.Resources.Views.Auth.ChangePassword", typeof(ChangePassword).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Change Password. - /// - public static string ChangePasswordKey { - get { - return ResourceManager.GetString("ChangePasswordKey", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Current Password. - /// - public static string CurrentPassword { - get { - return ResourceManager.GetString("CurrentPassword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enter your existing password to verify your identity. - /// - public static string DescriptionCurrentPassword { - get { - return ResourceManager.GetString("DescriptionCurrentPassword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password must be at least 8 characters and include letters, numbers, and symbols. - /// - public static string DescriptionNewPassword { - get { - return ResourceManager.GetString("DescriptionNewPassword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Re-enter your new password to ensure it matches. - /// - public static string DescriptionNewPasswordConfirm { - get { - return ResourceManager.GetString("DescriptionNewPasswordConfirm", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New Password. - /// - public static string NewPassword { - get { - return ResourceManager.GetString("NewPassword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New Password Confirm. - /// - public static string NewPasswordConfirm { - get { - return ResourceManager.GetString("NewPasswordConfirm", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password Changed. - /// - public static string PasswordChanged { - get { - return ResourceManager.GetString("PasswordChanged", resourceCulture); - } - } - } -} diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/Login.Designer.cs b/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/Login.Designer.cs deleted file mode 100644 index 52d807db..00000000 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/Login.Designer.cs +++ /dev/null @@ -1,117 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Lumina.Presentation.Web.Core.Resources.Views.Auth { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Login { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Login() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lumina.Presentation.Web.Core.Resources.Views.Auth.Login", typeof(Login).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Login. - /// - public static string LoginKey { - get { - return ResourceManager.GetString("LoginKey", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password. - /// - public static string Password { - get { - return ResourceManager.GetString("Password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Recover Password. - /// - public static string RecoverPassword { - get { - return ResourceManager.GetString("RecoverPassword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to TOTP Code. - /// - public static string TotpCode { - get { - return ResourceManager.GetString("TotpCode", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Username. - /// - public static string Username { - get { - return ResourceManager.GetString("Username", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Validate Code. - /// - public static string ValidateCode { - get { - return ResourceManager.GetString("ValidateCode", resourceCulture); - } - } - } -} diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/RecoverPassword.Designer.cs b/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/RecoverPassword.Designer.cs deleted file mode 100644 index ced70740..00000000 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/RecoverPassword.Designer.cs +++ /dev/null @@ -1,117 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Lumina.Presentation.Web.Core.Resources.Views.Auth { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class RecoverPassword { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal RecoverPassword() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lumina.Presentation.Web.Core.Resources.Views.Auth.RecoverPassword", typeof(RecoverPassword).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Back To Login. - /// - public static string BackToLogin { - get { - return ResourceManager.GetString("BackToLogin", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Login. - /// - public static string Login { - get { - return ResourceManager.GetString("Login", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password Temporarily Reset. - /// - public static string PasswordTemporarilyReset { - get { - return ResourceManager.GetString("PasswordTemporarilyReset", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to TOTP Code. - /// - public static string TotpCode { - get { - return ResourceManager.GetString("TotpCode", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Username. - /// - public static string Username { - get { - return ResourceManager.GetString("Username", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Validate Code. - /// - public static string ValidateCode { - get { - return ResourceManager.GetString("ValidateCode", resourceCulture); - } - } - } -} diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/Register.Designer.cs b/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/Register.Designer.cs deleted file mode 100644 index 0c6c5c0f..00000000 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Auth/Register.Designer.cs +++ /dev/null @@ -1,189 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Lumina.Presentation.Web.Core.Resources.Views.Auth { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Register { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Register() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lumina.Presentation.Web.Core.Resources.Views.Auth.Register", typeof(Register).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Account Created. - /// - public static string AccountCreated { - get { - return ResourceManager.GetString("AccountCreated", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Admin account registration. - /// - public static string AdminAccountRegistration { - get { - return ResourceManager.GetString("AdminAccountRegistration", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Recommended for account security and required for password recovery. - /// - public static string Description2Fa { - get { - return ResourceManager.GetString("Description2Fa", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password must be at least 8 characters and include letters, numbers, and symbols. - /// - public static string DescriptionPassword { - get { - return ResourceManager.GetString("DescriptionPassword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Re-enter your password to ensure it matches. - /// - public static string DescriptionPasswordConfirm { - get { - return ResourceManager.GetString("DescriptionPasswordConfirm", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Choose a unique username for your account (3-20 characters). - /// - public static string DescriptionUsername { - get { - return ResourceManager.GetString("DescriptionUsername", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password recovery is allowed only if two factor authentication is enabled!. - /// - public static string DisclaimerTwoFactor { - get { - return ResourceManager.GetString("DisclaimerTwoFactor", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enable two factor authentication. - /// - public static string EnableTwoFactorAuthentication { - get { - return ResourceManager.GetString("EnableTwoFactorAuthentication", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Login. - /// - public static string Login { - get { - return ResourceManager.GetString("Login", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password. - /// - public static string Password { - get { - return ResourceManager.GetString("Password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password Confirm. - /// - public static string PasswordConfirm { - get { - return ResourceManager.GetString("PasswordConfirm", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Register. - /// - public static string RegisterKey { - get { - return ResourceManager.GetString("RegisterKey", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Scan TOTP Code. - /// - public static string ScanTotpCode { - get { - return ResourceManager.GetString("ScanTotpCode", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Username. - /// - public static string Username { - get { - return ResourceManager.GetString("Username", resourceCulture); - } - } - } -} diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.Designer.cs b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.Designer.cs deleted file mode 100644 index 33123b17..00000000 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.Designer.cs +++ /dev/null @@ -1,720 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Lumina.Presentation.Web.Core.Resources.Views.Library.Management { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Item { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Item() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lumina.Presentation.Web.Core.Resources.Views.Library.Management.Item", typeof(Item).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Academic Paper. - /// - public static string AcademicPaper { - get { - return ResourceManager.GetString("AcademicPaper", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add directory. - /// - public static string AddDirectory { - get { - return ResourceManager.GetString("AddDirectory", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add image. - /// - public static string AddImage { - get { - return ResourceManager.GetString("AddImage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add New Library. - /// - public static string AddNewLibrary { - get { - return ResourceManager.GetString("AddNewLibrary", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Advanced Settings. - /// - public static string AdvancedSettings { - get { - return ResourceManager.GetString("AdvancedSettings", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Anime. - /// - public static string Anime { - get { - return ResourceManager.GetString("Anime", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Audio Book. - /// - public static string AudioBook { - get { - return ResourceManager.GetString("AudioBook", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Audio Content. - /// - public static string AudioContent { - get { - return ResourceManager.GetString("AudioContent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Back To Libraries. - /// - public static string BackToLibraries { - get { - return ResourceManager.GetString("BackToLibraries", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Book. - /// - public static string Book { - get { - return ResourceManager.GetString("Book", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Book Series. - /// - public static string BookSeries { - get { - return ResourceManager.GetString("BookSeries", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Comic Book. - /// - public static string ComicBook { - get { - return ResourceManager.GetString("ComicBook", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Comic Series. - /// - public static string ComicSeries { - get { - return ResourceManager.GetString("ComicSeries", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Concert. - /// - public static string Concert { - get { - return ResourceManager.GetString("Concert", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cover. - /// - public static string Cover { - get { - return ResourceManager.GetString("Cover", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cover Image. - /// - public static string CoverImage { - get { - return ResourceManager.GetString("CoverImage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Select the image file that will be used as the cover for this library. - /// - public static string DescriptionCover { - get { - return ResourceManager.GetString("DescriptionCover", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Select the folders containing the media files of this library. - /// - public static string DescriptionDirectories { - get { - return ResourceManager.GetString("DescriptionDirectories", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Whether this media library should get the metadata of it elements by downloading it from the Internet, or not.. - /// - public static string DescriptionDownloadMetadataFromWeb { - get { - return ResourceManager.GetString("DescriptionDownloadMetadataFromWeb", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Whether this media library is disabled or not. A disabled library is not displayed to the users, scanned, updated, etc.. - /// - public static string DescriptionEnabled { - get { - return ResourceManager.GetString("DescriptionEnabled", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Select the type of media content this library will contain. - /// - public static string DescriptionLibraryType { - get { - return ResourceManager.GetString("DescriptionLibraryType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Whether this media library is locked or not. A locked library is displayed to the users, but it is never scanned, updated, modified, etc.. - /// - public static string DescriptionLocked { - get { - return ResourceManager.GetString("DescriptionLocked", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The metadata providers used to enrich the items of this library, in the order they are tried.. - /// - public static string DescriptionMetadataProviders { - get { - return ResourceManager.GetString("DescriptionMetadataProviders", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Whether to save a copy of the downloaded metadata in the media library content locations directories, or not. This only has an effect if downloading metadata from the web is active.. - /// - public static string DescriptionShouldSaveMetadataInMediaDirectories { - get { - return ResourceManager.GetString("DescriptionShouldSaveMetadataInMediaDirectories", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to When enabled, this option uses directory metadata to skip directories that have not changed since the last scan. This can _significantly_ speed up scans, but be aware that directories metadata _does not_ change/update when editing existing files, it does so only when adding new files or deleting existing ones. Only enable this if you don't modify existing files.. - /// - public static string DescriptionShouldSkipUnchangedDirectoriesDuringScan { - get { - return ResourceManager.GetString("DescriptionShouldSkipUnchangedDirectoriesDuringScan", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A name to identify this library. - /// - public static string DescriptionTitle { - get { - return ResourceManager.GetString("DescriptionTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Directories. - /// - public static string Directories { - get { - return ResourceManager.GetString("Directories", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documentary. - /// - public static string Documentary { - get { - return ResourceManager.GetString("Documentary", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Download Metadata From The Web. - /// - public static string DownloadMetadataFromWeb { - get { - return ResourceManager.GetString("DownloadMetadataFromWeb", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to E Book. - /// - public static string EBook { - get { - return ResourceManager.GetString("EBook", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Edit Library. - /// - public static string EditLibrary { - get { - return ResourceManager.GetString("EditLibrary", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enabled. - /// - public static string Enabled { - get { - return ResourceManager.GetString("Enabled", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Film Franchise. - /// - public static string FilmFranchise { - get { - return ResourceManager.GetString("FilmFranchise", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Film Series. - /// - public static string FilmSeries { - get { - return ResourceManager.GetString("FilmSeries", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to General Information. - /// - public static string GeneralInformation { - get { - return ResourceManager.GetString("GeneralInformation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Graphic Novel. - /// - public static string GraphicNovel { - get { - return ResourceManager.GetString("GraphicNovel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Interview. - /// - public static string Interview { - get { - return ResourceManager.GetString("Interview", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Library Saved. - /// - public static string LibrarySaved { - get { - return ResourceManager.GetString("LibrarySaved", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Library Type. - /// - public static string LibraryType { - get { - return ResourceManager.GetString("LibraryType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Live Performance. - /// - public static string LivePerformance { - get { - return ResourceManager.GetString("LivePerformance", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Locked. - /// - public static string Locked { - get { - return ResourceManager.GetString("Locked", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Magazine. - /// - public static string Magazine { - get { - return ResourceManager.GetString("Magazine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Manga. - /// - public static string Manga { - get { - return ResourceManager.GetString("Manga", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Metadata providers. - /// - public static string MetadataProviders { - get { - return ResourceManager.GetString("MetadataProviders", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Miscellaneous Content. - /// - public static string MiscellaneousContent { - get { - return ResourceManager.GetString("MiscellaneousContent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Move down. - /// - public static string MoveDown { - get { - return ResourceManager.GetString("MoveDown", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Move up. - /// - public static string MoveUp { - get { - return ResourceManager.GetString("MoveUp", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Movie. - /// - public static string Movie { - get { - return ResourceManager.GetString("Movie", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Music. - /// - public static string Music { - get { - return ResourceManager.GetString("Music", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Name. - /// - public static string Name { - get { - return ResourceManager.GetString("Name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Order. - /// - public static string Order { - get { - return ResourceManager.GetString("Order", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Order saved. - /// - public static string OrderSaved { - get { - return ResourceManager.GetString("OrderSaved", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Other. - /// - public static string Other { - get { - return ResourceManager.GetString("Other", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Personal. - /// - public static string Personal { - get { - return ResourceManager.GetString("Personal", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Photo Album. - /// - public static string PhotoAlbum { - get { - return ResourceManager.GetString("PhotoAlbum", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Podcast. - /// - public static string Podcast { - get { - return ResourceManager.GetString("Podcast", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Radio Show. - /// - public static string RadioShow { - get { - return ResourceManager.GetString("RadioShow", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remix. - /// - public static string Remix { - get { - return ResourceManager.GetString("Remix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove. - /// - public static string Remove { - get { - return ResourceManager.GetString("Remove", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Save. - /// - public static string Save { - get { - return ResourceManager.GetString("Save", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Screenplay. - /// - public static string Screenplay { - get { - return ResourceManager.GetString("Screenplay", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Sheet Music. - /// - public static string SheetMusic { - get { - return ResourceManager.GetString("SheetMusic", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Save Metadata In Media Directories. - /// - public static string ShouldSaveMetadataInMediaDirectories { - get { - return ResourceManager.GetString("ShouldSaveMetadataInMediaDirectories", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Skip Unchanged Directories During Scan. - /// - public static string ShouldSkipUnchangedDirectoriesDuringScan { - get { - return ResourceManager.GetString("ShouldSkipUnchangedDirectoriesDuringScan", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Sound Effect. - /// - public static string Soundeffect { - get { - return ResourceManager.GetString("Soundeffect", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Title. - /// - public static string Title { - get { - return ResourceManager.GetString("Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tutorial. - /// - public static string Tutorial { - get { - return ResourceManager.GetString("Tutorial", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tv Show. - /// - public static string TvShow { - get { - return ResourceManager.GetString("TvShow", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Videoclip. - /// - public static string Videoclip { - get { - return ResourceManager.GetString("Videoclip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Video Content. - /// - public static string VideoContent { - get { - return ResourceManager.GetString("VideoContent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Visual Content. - /// - public static string VisualContent { - get { - return ResourceManager.GetString("VisualContent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Written Content. - /// - public static string WrittenContent { - get { - return ResourceManager.GetString("WrittenContent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to YouTube. - /// - public static string YouTube { - get { - return ResourceManager.GetString("YouTube", resourceCulture); - } - } - } -} diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ar-SA.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ar-SA.resx index d3d14645..472452b6 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ar-SA.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ar-SA.resx @@ -177,6 +177,9 @@ ما إذا كانت مكتبة الوسائط هذه معطّلة أم لا. المكتبة المعطّلة لا تُعرض على المستخدمين ولا تُفحص ولا تُحدَّث وما إلى ذلك. + + يشير إلى ما إذا كان محتوى مكتبة الوسائط مخزناً على قرص حالة صلبة. عند التفعيل، تقرأ مرحلتا اكتشاف الملفات وحساب تجزئة المحتوى الملفات بالتوازي، مما يستفيد من زمن الاستجابة المنخفض لأقراص الحالة الصلبة. اتركه معطلاً لأقراص القرص الصلب الميكانيكية، حيث قد تقلل القراءات المتوازية من الأداء. + حدد نوع محتوى الوسائط الذي ستحتويه هذه المكتبة @@ -225,6 +228,9 @@ مقابلة + + المحتوى على قرص SSD + تم حفظ المكتبة diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.de-DE.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.de-DE.resx index c6661aa2..3951cc56 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.de-DE.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.de-DE.resx @@ -177,6 +177,9 @@ Ob diese Medienbibliothek deaktiviert ist oder nicht. Eine deaktivierte Bibliothek wird den Benutzern nicht angezeigt, nicht gescannt, nicht aktualisiert, usw. + + Ob der Inhalt der Medienbibliothek auf einer Solid State Drive gespeichert ist. Wenn aktiviert, lesen die Dateierkennung und das Hashen der Inhalte Dateien parallel, was die geringe Latenz von Solid State Drives nutzt. Für mechanische Festplatten deaktiviert lassen, da parallele Lesezugriffe die Leistung verringern können. + Wählen Sie die Art der Medieninhalte aus, die diese Bibliothek enthalten soll @@ -225,6 +228,9 @@ Interview + + Inhalt liegt auf SSD + Bibliothek Gespeichert diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.en-US.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.en-US.resx index 55cf7fc0..69679d6a 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.en-US.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.en-US.resx @@ -177,6 +177,9 @@ Whether this media library is disabled or not. A disabled library is not displayed to the users, scanned, updated, etc. + + Whether the media library content is stored on a solid state drive. When enabled, the file discovery and content hashing stages read files in parallel, which takes advantage of the low latency of solid state drives. Leave it off for mechanical hard drives, where parallel reads can reduce performance. + Select the type of media content this library will contain @@ -225,6 +228,9 @@ Interview + + Content Is On SSD + Library Saved diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.es-ES.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.es-ES.resx index 4393c46b..70d5c756 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.es-ES.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.es-ES.resx @@ -177,6 +177,9 @@ Si esta biblioteca multimedia está desactivada o no. Una biblioteca desactivada no se muestra a los usuarios, no se escanea, no se actualiza, etc. + + Indica si el contenido de la biblioteca multimedia está almacenado en una unidad de estado sólido. Cuando se activa, las etapas de descubrimiento de archivos y de cálculo de hash del contenido leen archivos en paralelo, aprovechando la baja latencia de las unidades de estado sólido. Déjalo desactivado para discos duros mecánicos, donde las lecturas en paralelo pueden reducir el rendimiento. + Selecciona el tipo de contenido multimedia que contendrá esta biblioteca @@ -225,6 +228,9 @@ Entrevista + + El contenido está en SSD + Biblioteca Guardada diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.fr-FR.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.fr-FR.resx index 21012df1..05c47ce0 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.fr-FR.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.fr-FR.resx @@ -177,6 +177,9 @@ Si cette médiathèque est désactivée ou non. Une bibliothèque désactivée n'est pas affichée aux utilisateurs, ni analysée, ni mise à jour, etc. + + Indique si le contenu de la médiathèque est stocké sur un disque SSD. Lorsque cette option est activée, les étapes de découverte des fichiers et de calcul des empreintes du contenu lisent les fichiers en parallèle, ce qui tire parti de la faible latence des disques SSD. Laissez-la désactivée pour les disques durs mécaniques, où les lectures parallèles peuvent réduire les performances. + Choisissez le type de contenu multimédia que contiendra cette bibliothèque @@ -225,6 +228,9 @@ Entretien + + Contenu sur SSD + Bibliothèque Enregistrée diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.it-IT.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.it-IT.resx index 187f2f32..6141fb44 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.it-IT.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.it-IT.resx @@ -177,6 +177,9 @@ Se questa libreria multimediale è disabilitata o meno. Una libreria disabilitata non viene mostrata agli utenti, scansionata, aggiornata, ecc. + + Indica se il contenuto della libreria multimediale è archiviato su un'unità a stato solido. Quando è attiva, le fasi di individuazione dei file e di calcolo dell'hash del contenuto leggono i file in parallelo, sfruttando la bassa latenza delle unità a stato solido. Lasciarla disattivata per i dischi rigidi meccanici, dove le letture parallele possono ridurre le prestazioni. + Seleziona il tipo di contenuti multimediali che questa biblioteca conterrà @@ -225,6 +228,9 @@ Intervista + + Contenuto su SSD + Biblioteca Salvata diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ja-JP.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ja-JP.resx index 14f61cd4..4dcdd3f0 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ja-JP.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ja-JP.resx @@ -177,6 +177,9 @@ このメディアライブラリが無効になっているかどうか。無効化されたライブラリはユーザーに表示されず、スキャンされず、更新もされません。 + + メディアライブラリのコンテンツがソリッドステートドライブに保存されているかどうか。有効にすると、ファイル検出とコンテンツのハッシュ計算の段階で複数のファイルを並列で読み取り、ソリッドステートドライブの低遅延を活用します。並列読み取りがパフォーマンスを低下させる可能性があるメカニカルハードディスクでは無効のままにしてください。 + この図書館に含める媒体コンテンツの種類を選択してください @@ -225,6 +228,9 @@ インタビュー + + コンテンツはSSD上にあります + ライブラリを保存しました diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.resx index 55cf7fc0..69679d6a 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.resx @@ -177,6 +177,9 @@ Whether this media library is disabled or not. A disabled library is not displayed to the users, scanned, updated, etc. + + Whether the media library content is stored on a solid state drive. When enabled, the file discovery and content hashing stages read files in parallel, which takes advantage of the low latency of solid state drives. Leave it off for mechanical hard drives, where parallel reads can reduce performance. + Select the type of media content this library will contain @@ -225,6 +228,9 @@ Interview + + Content Is On SSD + Library Saved diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ro-RO.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ro-RO.resx index 2543870b..285d7a4f 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ro-RO.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.ro-RO.resx @@ -177,6 +177,9 @@ Dacă această bibliotecă media este dezactivată sau nu. O bibliotecă dezactivată nu este afișată utilizatorilor, scanată, actualizată, etc. + + Stabilește dacă fișierele bibliotecii media se află pe un SSD. Când este activată, etapele de descoperire a fișierelor și de calculare a amprentelor conținutului citesc fișierele în paralel, valorificând latența redusă a unităților SSD. Lăsați-o dezactivată pentru hard disk-urile mecanice, unde citirile în paralel pot reduce performanța. + Selectează tipul de conținut media pe care îl va conține această bibliotecă @@ -225,6 +228,9 @@ Interviu + + Conținutul este pe SSD + Biblioteca A Fost Salvată diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.uk-UA.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.uk-UA.resx index 5e1c4241..4de84f09 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.uk-UA.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.uk-UA.resx @@ -177,6 +177,9 @@ Чи вимкнена ця медіатека чи ні. Вимкнена бібліотека не відображається користувачам, не сканується, не оновлюється тощо. + + Вказує, чи зберігається вміст медіатеки на твердотільному накопичувачі. Якщо ввімкнено, етапи виявлення файлів і обчислення хешу вмісту читають файли паралельно, використовуючи низьку затримку твердотільних накопичувачів. Залиште вимкненим для механічних жорстких дисків, де паралельне читання може знизити продуктивність. + Виберіть тип медіаконтенту, який міститиме ця бібліотека @@ -225,6 +228,9 @@ Інтерв'ю + + Вміст на SSD + Бібліотеку збережено diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.zh-CN.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.zh-CN.resx index ec7ff75a..ca2f34b4 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.zh-CN.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Library/Management/Item.zh-CN.resx @@ -177,6 +177,9 @@ 此媒体库是否已禁用。禁用的库不会显示给用户,不会被扫描、更新等。 + + 媒体库内容是否存储在固态硬盘上。启用后,文件发现和内容哈希计算阶段会并行读取文件,从而利用固态硬盘的低延迟。对于机械硬盘,请保持关闭,因为并行读取可能会降低性能。 + 选择这个图书馆将包含的媒体内容类型 @@ -225,6 +228,9 @@ 访谈 + + 内容位于固态硬盘 + 图书馆已保存 diff --git a/src/Lumina.Presentation.Web/Core/Views/Library/Management/Item.cshtml b/src/Lumina.Presentation.Web/Core/Views/Library/Management/Item.cshtml index 32908860..861c09d4 100644 --- a/src/Lumina.Presentation.Web/Core/Views/Library/Management/Item.cshtml +++ b/src/Lumina.Presentation.Web/Core/Views/Library/Management/Item.cshtml @@ -205,6 +205,18 @@ @_localizer["DescriptionShouldSkipUnchangedDirectoriesDuringScan"] +
+
+ +
+
+ +
+ @_localizer["DescriptionIsContentOnSsd"] +
: @@ -343,6 +355,7 @@ const chkCanDownloadMetadataFromWeb = form.querySelector('[name="CanDownloadMetadataFromWeb"]'); const chkShouldSaveMetadataInMediaDirectories = form.querySelector('[name="ShouldSaveMetadataInMediaDirectories"]'); const chkShouldSkipUnchangedDirectoriesDuringScan = form.querySelector('[name="ShouldSkipUnchangedDirectoriesDuringScan"]'); + const chkIsContentOnSsd = form.querySelector('[name="IsContentOnSsd"]'); const chkShouldTrackConsumptionProgress = form.querySelector('[name="ShouldTrackConsumptionProgress"]'); const inputCompletionThresholdPercentage = form.querySelector('[name="CompletionThresholdPercentage"]'); const completionThresholdValidation = document.getElementById('completion-threshold-validation'); @@ -376,6 +389,7 @@ CanDownloadMetadataFromWeb: chkCanDownloadMetadataFromWeb.checked, ShouldSaveMetadataInMediaDirectories: chkShouldSaveMetadataInMediaDirectories.checked, ShouldSkipUnchangedDirectoriesDuringScan: chkShouldSkipUnchangedDirectoriesDuringScan.checked, + IsContentOnSsd: chkIsContentOnSsd.checked, ShouldTrackConsumptionProgress: shouldTrackConsumptionProgress, // An empty threshold is sent as null: creating a library or enabling progress tracking uses the type default, // editing a library that already tracks progress keeps the stored threshold, and types without a default diff --git a/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj b/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj index 0190e8d0..fb2baeab 100644 --- a/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj +++ b/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj @@ -47,31 +47,6 @@ True Plugins.resx - - True - True - ChangePassword.resx - - - True - True - Login.resx - - - True - True - RecoverPassword.resx - - - True - True - Register.resx - - - True - True - Item.resx - @@ -241,40 +216,6 @@ PublicResXFileCodeGenerator - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - Item.Designer.cs - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - - - PublicResXFileCodeGenerator - PublicResXFileCodeGenerator diff --git a/src/Lumina.sln b/src/Lumina.sln index a43c8b01..d5e73ecf 100644 --- a/src/Lumina.sln +++ b/src/Lumina.sln @@ -194,6 +194,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "architecture-decision-log", ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decision-record-0016.md = ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decision-record-0016.md ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decision-record-0017.md = ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decision-record-0017.md ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decision-record-0018.md = ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decision-record-0018.md + ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decision-record-0019.md = ..\docs\technical\architecture\architecture-knowledge-management\architecture-decision-log\architecture-decision-record-0019.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "domain", "domain", "{3EE8EFDF-4D55-4EA3-BEE2-74D00CB50570}" diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntityFixture.cs index 8f2d84cc..33455760 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntityFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntityFixture.cs @@ -33,6 +33,7 @@ public class LibraryEntityFixture /// Whether the media library should download metadata from the web or not. /// Whether the metadata should be saved in the media directories or not. /// Whether unchanged directories should be skipped during a scan or not. + /// Whether the content of the media library is stored on a solid state drive. /// Whether the consumption progress of the media library items is tracked. /// The percentage of a media library item that must be consumed for its session to be considered completed. /// Optional. The fingerprint of the metadata provider configuration of the media library. @@ -52,6 +53,7 @@ public class LibraryEntityFixture bool canDownloadMetadataFromWeb = true, bool shouldSaveMetadataInMediaDirectories = true, bool shouldSkipUnchangedDirectoriesDuringScan = false, + bool isContentOnSsd = false, bool shouldTrackConsumptionProgress = false, int? completionThresholdPercentage = null, string? metadataProvidersConfigurationFingerprint = null, @@ -75,6 +77,7 @@ public class LibraryEntityFixture CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb, ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories, ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan, + IsContentOnSsd = isContentOnSsd, ShouldTrackConsumptionProgress = shouldTrackConsumptionProgress, CompletionThresholdPercentage = completionThresholdPercentage, MetadataProvidersConfigurationFingerprint = metadataProvidersConfigurationFingerprint, diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandFixture.cs index d79c7a77..f773e3b5 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandFixture.cs @@ -28,6 +28,7 @@ public class AddLibraryCommandFixture /// Whether the media library should download metadata from the web or not. /// Whether the metadata should be saved in the media directories or not. /// Whether unchanged directories should be skipped during a scan or not. + /// Whether the content of the media library is stored on a solid state drive. /// Optional. Whether the consumption progress of the media library items should be tracked, or not. /// Optional. The percentage of a media library item that must be consumed for its session to be considered completed. /// Optional. The ordered parts of the path template of the media library. @@ -42,6 +43,7 @@ public class AddLibraryCommandFixture bool canDownloadMetadataFromWeb = true, bool shouldSaveMetadataInMediaDirectories = true, bool shouldSkipUnchangedDirectoriesDuringScan = false, + bool isContentOnSsd = false, bool? shouldTrackConsumptionProgress = null, int? completionThresholdPercentage = null, LibraryPathTemplatePartDto[]? pathTemplateParts = null) @@ -57,6 +59,7 @@ public class AddLibraryCommandFixture true, true, false, + false, shouldTrackConsumptionProgress, completionThresholdPercentage, null @@ -70,6 +73,7 @@ public class AddLibraryCommandFixture .RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb) .RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories) .RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan) + .RuleFor(x => x.IsContentOnSsd, isContentOnSsd) .RuleFor(x => x.PathTemplateParts, pathTemplateParts) .Generate(); } diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandFixture.cs index 8e46d17e..84bb39e0 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandFixture.cs @@ -31,6 +31,7 @@ public class UpdateLibraryCommandFixture /// Whether the media library should download metadata from the web or not. /// Whether the metadata should be saved in the media directories or not. /// Whether unchanged directories should be skipped during a scan or not. + /// Whether the content of the media library is stored on a solid state drive. /// Optional. Whether the consumption progress of the media library items should be tracked, or not. /// Optional. The percentage of a media library item that must be consumed for its session to be considered completed. /// Optional. The ordered parts of the path template of the media library. @@ -47,6 +48,7 @@ public class UpdateLibraryCommandFixture bool canDownloadMetadataFromWeb = true, bool shouldSaveMetadataInMediaDirectories = true, bool shouldSkipUnchangedDirectoriesDuringScan = false, + bool isContentOnSsd = false, bool? shouldTrackConsumptionProgress = null, int? completionThresholdPercentage = null, LibraryPathTemplatePartDto[]? pathTemplateParts = null) @@ -64,6 +66,7 @@ public class UpdateLibraryCommandFixture true, true, false, + false, shouldTrackConsumptionProgress, completionThresholdPercentage, null @@ -79,6 +82,7 @@ public class UpdateLibraryCommandFixture .RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb) .RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories) .RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan) + .RuleFor(x => x.IsContentOnSsd, isContentOnSsd) .RuleFor(x => x.PathTemplateParts, pathTemplateParts) .Generate(); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/Management/AddLibraryRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/Management/AddLibraryRequestFixture.cs index e4028f25..c705b5a7 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/Management/AddLibraryRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/Management/AddLibraryRequestFixture.cs @@ -28,6 +28,7 @@ public class AddLibraryRequestFixture /// Optional. Whether metadata should be downloaded from the web. /// Optional. Whether metadata should be saved in the media directories. /// Optional. Whether unchanged directories should be skipped during scan. + /// Optional. Whether the content of the media library is stored on a solid state drive. /// Optional. Whether the consumption progress of the media library items should be tracked, or not. /// Optional. The percentage of a media library item that must be consumed for its session to be considered completed. /// Optional. The ordered parts of the path template of the media library. @@ -42,6 +43,7 @@ public class AddLibraryRequestFixture bool? canDownloadMetadataFromWeb = null, bool? shouldSaveMetadataInMediaDirectories = null, bool? shouldSkipUnchangedDirectoriesDuringScan = null, + bool? isContentOnSsd = null, bool? shouldTrackConsumptionProgress = null, int? completionThresholdPercentage = null, LibraryPathTemplatePartRequest[]? pathTemplateParts = null) @@ -56,6 +58,7 @@ public class AddLibraryRequestFixture canDownloadMetadataFromWeb ?? _faker.Random.Bool(), shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(), shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(), + isContentOnSsd ?? false, shouldTrackConsumptionProgress, completionThresholdPercentage, pathTemplateParts diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/Management/UpdateLibraryRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/Management/UpdateLibraryRequestFixture.cs index 289ebfd7..44208473 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/Management/UpdateLibraryRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/Management/UpdateLibraryRequestFixture.cs @@ -31,6 +31,7 @@ public class UpdateLibraryRequestFixture /// Optional. Whether metadata should be downloaded from the web. /// Optional. Whether metadata should be saved in the media directories. /// Optional. Whether unchanged directories should be skipped during scan. + /// Optional. Whether the content of the media library is stored on a solid state drive. /// Optional. Whether the consumption progress of the media library items should be tracked, or not. /// Optional. The percentage of a media library item that must be consumed for its session to be considered completed. /// Optional. The ordered parts of the path template of the media library. @@ -47,6 +48,7 @@ public class UpdateLibraryRequestFixture bool? canDownloadMetadataFromWeb = null, bool? shouldSaveMetadataInMediaDirectories = null, bool? shouldSkipUnchangedDirectoriesDuringScan = null, + bool? isContentOnSsd = null, bool? shouldTrackConsumptionProgress = null, int? completionThresholdPercentage = null, LibraryPathTemplatePartRequest[]? pathTemplateParts = null) @@ -63,6 +65,7 @@ public class UpdateLibraryRequestFixture canDownloadMetadataFromWeb ?? _faker.Random.Bool(), shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(), shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(), + isContentOnSsd ?? false, shouldTrackConsumptionProgress, completionThresholdPercentage, pathTemplateParts diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/Management/LibraryResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/Management/LibraryResponseFixture.cs index d1dcb2dd..f90ad79c 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/Management/LibraryResponseFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/Management/LibraryResponseFixture.cs @@ -32,6 +32,7 @@ public class LibraryResponseFixture /// Optional. Whether metadata should be downloaded from the web. /// Optional. Whether metadata should be saved in the media directories. /// Optional. Whether unchanged directories should be skipped during scan. + /// Optional. Whether the content of the media library is stored on a solid state drive. /// Optional. Whether the consumption progress of the media library items is tracked. /// Optional. The percentage of a media library item that must be consumed for its session to be considered completed. /// Optional. The ordered parts of the path template of the media library. @@ -50,6 +51,7 @@ public class LibraryResponseFixture bool? canDownloadMetadataFromWeb = null, bool? shouldSaveMetadataInMediaDirectories = null, bool? shouldSkipUnchangedDirectoriesDuringScan = null, + bool? isContentOnSsd = null, bool? shouldTrackConsumptionProgress = null, int? completionThresholdPercentage = null, List? pathTemplateParts = null, @@ -70,6 +72,7 @@ public class LibraryResponseFixture canDownloadMetadataFromWeb ?? _faker.Random.Bool(), shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(), shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(), + isContentOnSsd ?? false, resolvedShouldTrackConsumptionProgress, resolvedCompletionThresholdPercentage, pathTemplateParts ?? [], diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryFixture.cs index e1d9489b..949d8c20 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryFixture.cs @@ -43,6 +43,7 @@ public class LibraryFixture /// Whether metadata download from the web is enabled. /// Whether metadata should be saved in the media directories. /// Whether unchanged directories should be skipped during scan. + /// Whether the content of the library is stored on a solid state drive. /// Optional. The consumption settings of the library. /// Optional. The scan Ids associated with the library. /// Optional. The path template of the library. @@ -60,6 +61,7 @@ public class LibraryFixture bool canDownloadMetadataFromWeb = true, bool shouldSaveMetadataInMediaDirectories = false, bool shouldSkipUnchangedDirectoriesDuringScan = false, + bool isContentOnSsd = false, LibraryConsumptionSettings? consumptionSettings = null, IEnumerable? scanIds = null, LibraryPathTemplate? pathTemplate = null, @@ -91,6 +93,7 @@ public class LibraryFixture canDownloadMetadataFromWeb, shouldSaveMetadataInMediaDirectories, shouldSkipUnchangedDirectoriesDuringScan, + isContentOnSsd, resolvedConsumptionSettings, pathTemplate ?? LibraryPathTemplate.Empty(), resolvedScanIds @@ -107,6 +110,7 @@ public class LibraryFixture canDownloadMetadataFromWeb, shouldSaveMetadataInMediaDirectories, shouldSkipUnchangedDirectoriesDuringScan, + isContentOnSsd, resolvedConsumptionSettings, pathTemplate ?? LibraryPathTemplate.Empty(), resolvedScanIds diff --git a/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/Repositories/Libraries/LibraryRepositoryTests.cs b/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/Repositories/Libraries/LibraryRepositoryTests.cs index 8fb7b783..86f95e34 100644 --- a/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/Repositories/Libraries/LibraryRepositoryTests.cs +++ b/tests/IntegrationTests/Lumina.DataAccess.IntegrationTests/Core/Repositories/Libraries/LibraryRepositoryTests.cs @@ -148,6 +148,31 @@ public class LibraryRepositoryTests Assert.Null(storedLibrary.CompletionThresholdPercentage); } + [Fact] + public async Task InsertAsync_WhenLibraryContentIsOnSsd_ShouldPersistTheSetting() + { + // Arrange + using SqliteConnection anchorConnection = new($"Data Source=luminadataccess-libraryrepo-insert-ssd-{Guid.NewGuid()};Mode=Memory;Cache=Shared"); + anchorConnection.Open(); + Guid userId = Guid.NewGuid(); + DateTime utcNow = new(2025, 1, 1, 12, 0, 0, DateTimeKind.Utc); + using LuminaDbContext context = CreateAuditedContext(anchorConnection, userId, utcNow); + LibraryRepository sut = new(context); + context.Users.Add(_userEntityFixture.Create(id: userId)); + LibraryEntity library = _libraryEntityFixture.Create(userId: userId, isContentOnSsd: true, contentLocations: []); + + // Act + Result result = await sut.InsertAsync(library, CancellationToken.None); + await context.SaveChangesAsync(); + + // Assert + Assert.False(result.IsFailure); + Assert.Equal(Result.Created, result.Value); + LibraryEntity? storedLibrary = await context.Libraries.AsNoTracking().FirstOrDefaultAsync(candidate => candidate.Id == library.Id); + Assert.NotNull(storedLibrary); + Assert.True(storedLibrary!.IsContentOnSsd); + } + [Fact] public async Task UpdateAsync_WhenConsumptionSettingsAreEnabled_ShouldPersistTheTrackingAndThreshold() { diff --git a/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJobTests.cs b/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJobTests.cs index cdd3a0e8..f63063e6 100644 --- a/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJobTests.cs +++ b/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJobTests.cs @@ -81,7 +81,7 @@ public class BooksFileSystemDiscoveryJobTests _scanId = _scanIdFixture.Create(); _userId = _userIdFixture.Create(); _libraryId = _libraryIdFixture.Create(); - _sut = new BooksFileSystemDiscoveryJob(_mockServiceScopeFactory) + _sut = new BooksFileSystemDiscoveryJob(_mockServiceScopeFactory, Substitute.For>()) { ScanId = _scanId, UserId = _userId, @@ -105,7 +105,8 @@ public class BooksFileSystemDiscoveryJobTests title: "Test Library", libraryType: LibraryType.Book, contentLocations: [temporaryLibraryDirectory.Path], - shouldSkipUnchangedDirectoriesDuringScan: false); + shouldSkipUnchangedDirectoriesDuringScan: false, + isContentOnSsd: true); _mockLibraryRepository.GetByIdAsync(_libraryId.Value, cancellationToken: Arg.Any()) .Returns(Result.From(libraryEntity)); _mockStagingResultsRepository.InsertRangeAsync(Arg.Any>(), Arg.Any()) diff --git a/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/Security/FileHashServiceTests.cs b/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/Security/FileHashServiceTests.cs index bdd99113..88795640 100644 --- a/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/Security/FileHashServiceTests.cs +++ b/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/Security/FileHashServiceTests.cs @@ -40,6 +40,7 @@ public class FileHashServiceTests // Act List result = await _sut.HashFilesAsync( inputFiles, + shouldParallelizeReads: true, () => { callbackInvocationCount++; @@ -66,7 +67,7 @@ public class FileHashServiceTests List inputFiles = [_hashedFileSystemFileDtoFixture.Create(path: filePath, size: new FileInfo(filePath).Length, currentHash: 0, oldHash: 0, ticks: 0)]; // Act - List result = await _sut.HashFilesAsync(inputFiles, () => Task.CompletedTask, CancellationToken.None); + List result = await _sut.HashFilesAsync(inputFiles, shouldParallelizeReads: true, () => Task.CompletedTask, CancellationToken.None); // Assert HashedFileSystemFileDto hashedFile = Assert.Single(result); @@ -83,10 +84,10 @@ public class FileHashServiceTests List firstInputFiles = [_hashedFileSystemFileDtoFixture.Create(path: filePath, size: new FileInfo(filePath).Length, currentHash: 0, oldHash: 0, ticks: 0)]; // Act - List firstResult = await _sut.HashFilesAsync(firstInputFiles, () => Task.CompletedTask, CancellationToken.None); + List firstResult = await _sut.HashFilesAsync(firstInputFiles, shouldParallelizeReads: true, () => Task.CompletedTask, CancellationToken.None); await File.WriteAllTextAsync(filePath, "changed content"); List secondInputFiles = [_hashedFileSystemFileDtoFixture.Create(path: filePath, size: new FileInfo(filePath).Length, currentHash: 0, oldHash: 0, ticks: 0)]; - List secondResult = await _sut.HashFilesAsync(secondInputFiles, () => Task.CompletedTask, CancellationToken.None); + List secondResult = await _sut.HashFilesAsync(secondInputFiles, shouldParallelizeReads: true, () => Task.CompletedTask, CancellationToken.None); // Assert Assert.NotEqual(firstResult[0].CurrentHash, secondResult[0].CurrentHash); @@ -100,7 +101,7 @@ public class FileHashServiceTests List inputFiles = [_hashedFileSystemFileDtoFixture.Create(path: nonExistentFilePath, size: 100, currentHash: 0, oldHash: 0, ticks: 0)]; // Act - List result = await _sut.HashFilesAsync(inputFiles, () => Task.CompletedTask, CancellationToken.None); + List result = await _sut.HashFilesAsync(inputFiles, shouldParallelizeReads: true, () => Task.CompletedTask, CancellationToken.None); // Assert Assert.Empty(result); @@ -119,7 +120,7 @@ public class FileHashServiceTests ]; // Act - List result = await _sut.HashFilesAsync(inputFiles, () => Task.CompletedTask, CancellationToken.None); + List result = await _sut.HashFilesAsync(inputFiles, shouldParallelizeReads: true, () => Task.CompletedTask, CancellationToken.None); // Assert HashedFileSystemFileDto hashedFile = Assert.Single(result); @@ -127,6 +128,37 @@ public class FileHashServiceTests Assert.NotEqual(0UL, hashedFile.CurrentHash); } + [Fact] + public async Task HashFilesAsync_WhenReadsAreNotParallelized_ShouldHashAllFilesSequentially() + { + // Arrange + using TemporaryTestDirectory temporaryTestDirectory = new(); + string filePath1 = temporaryTestDirectory.CreateFile("book1.pdf", "content of the first book"); + string filePath2 = temporaryTestDirectory.CreateFile("book2.pdf", "content of the second book"); + List inputFiles = + [ + _hashedFileSystemFileDtoFixture.Create(path: filePath1, size: new FileInfo(filePath1).Length, currentHash: 0, oldHash: 0, ticks: 0), + _hashedFileSystemFileDtoFixture.Create(path: filePath2, size: new FileInfo(filePath2).Length, currentHash: 0, oldHash: 0, ticks: 0) + ]; + int callbackInvocationCount = 0; + + // Act + List result = await _sut.HashFilesAsync( + inputFiles, + shouldParallelizeReads: false, + () => + { + callbackInvocationCount++; + return Task.CompletedTask; + }, + CancellationToken.None); + + // Assert + Assert.Equal(2, result.Count); + Assert.Equal(2, callbackInvocationCount); + Assert.All(result, file => Assert.NotEqual(0UL, file.CurrentHash)); + } + [Fact] public async Task HashFilesAsync_WhenCancellationRequested_ShouldCancelOperation() { @@ -138,7 +170,7 @@ public class FileHashServiceTests cancellationTokenSource.Cancel(); // Act - Task> operation = _sut.HashFilesAsync(inputFiles, () => Task.CompletedTask, cancellationTokenSource.Token); + Task> operation = _sut.HashFilesAsync(inputFiles, shouldParallelizeReads: true, () => Task.CompletedTask, cancellationTokenSource.Token); // Assert await Assert.ThrowsAnyAsync(() => operation); @@ -182,7 +214,7 @@ public class FileHashServiceTests List inputFiles = [_hashedFileSystemFileDtoFixture.Create(path: filePath, size: new FileInfo(filePath).Length, currentHash: 0, oldHash: 0, ticks: 0)]; // Act - List result = await _sut.HashFilesAsync(inputFiles, () => Task.CompletedTask, CancellationToken.None); + List result = await _sut.HashFilesAsync(inputFiles, shouldParallelizeReads: true, () => Task.CompletedTask, CancellationToken.None); // Assert HashedFileSystemFileDto hashedFile = Assert.Single(result); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs index e351c41c..427a8c83 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs @@ -32,6 +32,7 @@ public class AddMediaLibraryRequestMappingTests canDownloadMetadataFromWeb: true, shouldSaveMetadataInMediaDirectories: false, shouldSkipUnchangedDirectoriesDuringScan: false, + isContentOnSsd: true, shouldTrackConsumptionProgress: true, completionThresholdPercentage: 90 ); @@ -49,6 +50,7 @@ public class AddMediaLibraryRequestMappingTests Assert.Equal(request.IsLocked, result.IsLocked); Assert.Equal(request.CanDownloadMetadataFromWeb, result.CanDownloadMetadataFromWeb); Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories); + Assert.Equal(request.IsContentOnSsd, result.IsContentOnSsd); Assert.Equal(request.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress); Assert.Equal(request.CompletionThresholdPercentage, result.CompletionThresholdPercentage); } diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryEntityMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryEntityMappingTests.cs index a4957fe7..e3c122de 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryEntityMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryEntityMappingTests.cs @@ -32,7 +32,8 @@ public class LibraryEntityMappingTests title: "My Library", libraryType: LibraryType.Book, contentLocations: ["C:/Books", "D:/Media/Books"], - coverImage: "D:/myPoster.jpg"); + coverImage: "D:/myPoster.jpg", + isContentOnSsd: true); // Act LibraryResponse result = entity.ToResponse(); @@ -45,6 +46,7 @@ public class LibraryEntityMappingTests Assert.Equal(entity.LibraryType, result.LibraryType); Assert.Equal(entity.ContentLocations.Select(l => l.Path), result.ContentLocations); Assert.Equal(entity.CoverImage, result.CoverImage); + Assert.Equal(entity.IsContentOnSsd, result.IsContentOnSsd); Assert.Equal(entity.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress); Assert.Equal(entity.CompletionThresholdPercentage, result.CompletionThresholdPercentage); Assert.Equal(entity.CreatedOnUtc, result.CreatedOnUtc); @@ -188,6 +190,7 @@ public class LibraryEntityMappingTests libraryType: LibraryType.Book, contentLocations: ["C:/Books"], coverImage: "D:/cover.jpg", + isContentOnSsd: true, pathTemplateParts: [firstPart, secondPart]); // Act @@ -200,6 +203,7 @@ public class LibraryEntityMappingTests Assert.Equal(entity.Title, result.Value.Title); Assert.Equal(entity.LibraryType, result.Value.LibraryType); Assert.Equal("D:/cover.jpg", result.Value.CoverImage.Value); + Assert.Equal(entity.IsContentOnSsd, result.Value.IsContentOnSsd); Assert.Equal(entity.ShouldTrackConsumptionProgress, result.Value.ConsumptionSettings.ShouldTrackConsumptionProgress); Assert.Equal(entity.CompletionThresholdPercentage, result.Value.ConsumptionSettings.CompletionThresholdPercentage.HasValue ? result.Value.ConsumptionSettings.CompletionThresholdPercentage.Value : null); Assert.Equal(2, result.Value.PathTemplate.Parts.Count); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs index 6bb3f6a8..b7d84932 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs @@ -60,6 +60,7 @@ public class LibraryMappingTests Assert.False(result.IsLocked); Assert.True(result.CanDownloadMetadataFromWeb); Assert.False(result.ShouldSaveMetadataInMediaDirectories); + Assert.Equal(library.IsContentOnSsd, result.IsContentOnSsd); Assert.Equal(library.ConsumptionSettings.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress); Assert.Equal(library.ConsumptionSettings.CompletionThresholdPercentage.HasValue ? library.ConsumptionSettings.CompletionThresholdPercentage.Value : null, result.CompletionThresholdPercentage); Assert.Equal(library.ScanIds.Select(scanId => scanId.Value), result.LibraryScans.Select(libraryScan => libraryScan.Id)); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMappingTests.cs index 96d39b4b..9675c2b9 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMappingTests.cs @@ -32,6 +32,7 @@ public class UpdateLibraryRequestMappingTests canDownloadMetadataFromWeb: true, shouldSaveMetadataInMediaDirectories: false, shouldSkipUnchangedDirectoriesDuringScan: false, + isContentOnSsd: true, shouldTrackConsumptionProgress: true, completionThresholdPercentage: 90); @@ -49,6 +50,7 @@ public class UpdateLibraryRequestMappingTests Assert.Equal(request.CanDownloadMetadataFromWeb, result.CanDownloadMetadataFromWeb); Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories); Assert.Equal(request.ShouldSkipUnchangedDirectoriesDuringScan, result.ShouldSkipUnchangedDirectoriesDuringScan); + Assert.Equal(request.IsContentOnSsd, result.IsContentOnSsd); Assert.Equal(request.ShouldTrackConsumptionProgress, result.ShouldTrackConsumptionProgress); Assert.Equal(request.CompletionThresholdPercentage, result.CompletionThresholdPercentage); } diff --git a/tests/UnitTests/Lumina.DataAccess.UnitTests/Common/Configuration/LibraryConfigurationTests.cs b/tests/UnitTests/Lumina.DataAccess.UnitTests/Common/Configuration/LibraryConfigurationTests.cs index 0dbca57b..440b7bc7 100644 --- a/tests/UnitTests/Lumina.DataAccess.UnitTests/Common/Configuration/LibraryConfigurationTests.cs +++ b/tests/UnitTests/Lumina.DataAccess.UnitTests/Common/Configuration/LibraryConfigurationTests.cs @@ -62,6 +62,7 @@ public class LibraryConfigurationTests IProperty downloadMetadataProperty = entityType.GetProperty(nameof(LibraryEntity.CanDownloadMetadataFromWeb)); IProperty shouldTrackConsumptionProgressProperty = entityType.GetProperty(nameof(LibraryEntity.ShouldTrackConsumptionProgress)); IProperty completionThresholdPercentageProperty = entityType.GetProperty(nameof(LibraryEntity.CompletionThresholdPercentage)); + IProperty isContentOnSsdProperty = entityType.GetProperty(nameof(LibraryEntity.IsContentOnSsd)); // Assert Assert.False(titleProperty.IsNullable); @@ -76,6 +77,23 @@ public class LibraryConfigurationTests Assert.Equal(typeof(int?), completionThresholdPercentageProperty.ClrType); Assert.True(completionThresholdPercentageProperty.IsNullable); Assert.Null(completionThresholdPercentageProperty.GetDefaultValue()); + Assert.Equal(typeof(bool), isContentOnSsdProperty.ClrType); + Assert.False(isContentOnSsdProperty.IsNullable); + Assert.Equal(false, isContentOnSsdProperty.GetDefaultValue()); + } + + [Fact] + public void Configure_WhenApplied_ShouldConfigureSsdContentColumnOrder() + { + // Arrange + IEntityType entityType = DesignTimeModel.FindEntityType(typeof(LibraryEntity))!; + + // Act + IProperty isContentOnSsdProperty = entityType.GetProperty(nameof(LibraryEntity.IsContentOnSsd)); + + // Assert + Assert.Equal(18, isContentOnSsdProperty.GetColumnOrder()); + Assert.Equal(nameof(LibraryEntity.IsContentOnSsd), isContentOnSsdProperty.GetColumnName()); } [Fact] diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryTests.cs index bd183108..32f879d2 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/LibraryTests.cs @@ -56,6 +56,7 @@ public class LibraryTests canDownloadMetadataFromWeb: false, shouldSaveMetadataInMediaDirectories: true, shouldSkipUnchangedDirectoriesDuringScan: true, + isContentOnSsd: true, consumptionSettings, LibraryPathTemplate.Empty(), scanIds); @@ -73,6 +74,7 @@ public class LibraryTests Assert.False(result.Value.CanDownloadMetadataFromWeb); Assert.True(result.Value.ShouldSaveMetadataInMediaDirectories); Assert.True(result.Value.ShouldSkipUnchangedDirectoriesDuringScan); + Assert.True(result.Value.IsContentOnSsd); Assert.Equal(consumptionSettings, result.Value.ConsumptionSettings); Assert.Equal(scanIds, result.Value.ScanIds); } @@ -97,6 +99,7 @@ public class LibraryTests canDownloadMetadataFromWeb: true, shouldSaveMetadataInMediaDirectories: false, shouldSkipUnchangedDirectoriesDuringScan: false, + isContentOnSsd: false, _libraryConsumptionSettingsFixture.Create(), LibraryPathTemplate.Empty(), scanIds); @@ -125,6 +128,7 @@ public class LibraryTests canDownloadMetadataFromWeb: true, shouldSaveMetadataInMediaDirectories: false, shouldSkipUnchangedDirectoriesDuringScan: false, + isContentOnSsd: false, _libraryConsumptionSettingsFixture.Create(), LibraryPathTemplate.Empty(), []); @@ -162,6 +166,7 @@ public class LibraryTests canDownloadMetadataFromWeb: true, shouldSaveMetadataInMediaDirectories: false, shouldSkipUnchangedDirectoriesDuringScan: false, + isContentOnSsd: false, _libraryConsumptionSettingsFixture.Create(), LibraryPathTemplate.Empty(), []); @@ -191,6 +196,7 @@ public class LibraryTests canDownloadMetadataFromWeb: true, shouldSaveMetadataInMediaDirectories: false, shouldSkipUnchangedDirectoriesDuringScan: false, + isContentOnSsd: false, _libraryConsumptionSettingsFixture.Create(), LibraryPathTemplate.Empty(), []); diff --git a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/Audio/Music/MusicFileSystemDiscoveryJobTests.cs b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/Audio/Music/MusicFileSystemDiscoveryJobTests.cs index 00981ae7..a89be224 100644 --- a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/Audio/Music/MusicFileSystemDiscoveryJobTests.cs +++ b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/Audio/Music/MusicFileSystemDiscoveryJobTests.cs @@ -19,10 +19,12 @@ using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.U using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary; using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Audio.Music; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using NSubstitute; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -38,6 +40,7 @@ public class MusicFileSystemDiscoveryJobTests { private const string ROOT_PATH = @"C:\Music"; private const string AUDIO_FILE_PATH = @"C:\Music\song.mp3"; + private const string SECOND_AUDIO_FILE_PATH = @"C:\Music\other.mp3"; private const string IMAGE_FILE_PATH = @"C:\Music\cover.jpg"; private readonly IServiceScopeFactory _mockServiceScopeFactory; @@ -50,6 +53,7 @@ public class MusicFileSystemDiscoveryJobTests private readonly IFileProviderService _mockFileProviderService; private readonly IDirectoryProviderService _mockDirectoryProviderService; private readonly IDomainEventPublisher _mockDomainEventPublisher; + private readonly ILogger _mockLogger; private readonly MusicFileSystemDiscoveryJob _sut; private readonly LibraryEntityFixture _libraryEntityFixture = new(); private readonly DirectoryScanFingerprintEntityFixture _directoryScanFingerprintEntityFixture = new(); @@ -101,7 +105,9 @@ public class MusicFileSystemDiscoveryJobTests _libraryId = _libraryIdFixture.Create(); _scanId = _scanIdFixture.Create(); _userId = _userIdFixture.Create(); - _sut = new MusicFileSystemDiscoveryJob(_mockServiceScopeFactory) + _mockLogger = Substitute.For>(); + _mockLogger.IsEnabled(Arg.Any()).Returns(true); + _sut = new MusicFileSystemDiscoveryJob(_mockServiceScopeFactory, _mockLogger) { ScanId = _scanId, UserId = _userId, @@ -182,6 +188,45 @@ public class MusicFileSystemDiscoveryJobTests Arg.Any()); } + [Fact] + public async Task ExecuteAsync_WhenTheLibraryIsOnSsd_ShouldReadInParallelAndSkipFilesThatBecomeInaccessible() + { + // Arrange + SetupLibrary(isContentOnSsd: true); + SetupDirectory(ROOT_PATH, files: [AUDIO_FILE_PATH, SECOND_AUDIO_FILE_PATH, IMAGE_FILE_PATH], subdirectories: []); + _mockFileProviderService.GetSize(Arg.Is(path => path.Path == AUDIO_FILE_PATH)) + .Returns(_ => throw new IOException("The file vanished between enumeration and processing")); + _mockFileProviderService.GetSize(Arg.Is(path => path.Path == SECOND_AUDIO_FILE_PATH)).Returns(Result.From(1234L)); + _mockFileProviderService.GetLastWriteTime(Arg.Is(path => path.Path == SECOND_AUDIO_FILE_PATH)) + .Returns(Result.From(Optional.Some(new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc)))); + + // Act + await _sut.ExecuteAsync(Guid.NewGuid(), new { }, CancellationToken.None); + + // Assert + // The sequential path does not catch per-file IO exceptions, so completing here proves the parallel path was taken. + Assert.Equal(LibraryScanJobStatus.Completed, _sut.Status); + await _mockStagingResultsRepository.Received(1).InsertRangeAsync( + Arg.Is>(entities => entities.Count == 1 + && entities.First().Path == SECOND_AUDIO_FILE_PATH + && entities.First().Size == 1234 + && entities.First().LibraryScanId == _scanId.Value + && entities.First().NeedsRehash), + Arg.Any()); + _mockLogger.Received(1).Log( + LogLevel.Debug, + Arg.Any(), + Arg.Is(state => state.ToString()!.Contains("solid state drive", StringComparison.Ordinal)), + Arg.Any(), + Arg.Any>()); + _mockLogger.Received(1).Log( + LogLevel.Warning, + Arg.Any(), + Arg.Is(state => state.ToString()!.Contains(AUDIO_FILE_PATH, StringComparison.Ordinal)), + Arg.Any(), + Arg.Any>()); + } + [Fact] public async Task ExecuteAsync_WhenTheSubdirectoryHasAudioFiles_ShouldTraverseIntoIt() { @@ -301,6 +346,22 @@ public class MusicFileSystemDiscoveryJobTests await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is(domainEvent => domainEvent.LibraryId == _libraryId), Arg.Any()); } + [Fact] + public async Task ExecuteAsync_WhenAFileMetadataReadThrowsAnUnexpectedException_ShouldMarkJobAsFailed() + { + // Arrange + SetupLibrary(isContentOnSsd: true); + SetupDirectory(ROOT_PATH, files: [AUDIO_FILE_PATH], subdirectories: []); + _mockFileProviderService.GetSize(Arg.Any()).Returns(_ => throw new InvalidOperationException("Unexpected defect")); + + // Act + await _sut.ExecuteAsync(Guid.NewGuid(), new { }, CancellationToken.None); + + // Assert + Assert.Equal(LibraryScanJobStatus.Failed, _sut.Status); + await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is(domainEvent => domainEvent.LibraryId == _libraryId), Arg.Any()); + } + [Fact] public async Task ExecuteAsync_WhenTheFingerprintUpsertFails_ShouldMarkJobAsFailed() { @@ -342,13 +403,15 @@ public class MusicFileSystemDiscoveryJobTests /// Stubs the media library reader with a library whose single content location is the test root path. /// /// Whether the library skips the directories that have not changed since the last scan. - private void SetupLibrary(bool shouldSkipUnchangedDirectoriesDuringScan = false) + /// Whether the content of the library is stored on a solid state drive. + private void SetupLibrary(bool shouldSkipUnchangedDirectoriesDuringScan = false, bool isContentOnSsd = false) { LibraryEntity library = _libraryEntityFixture.Create( id: _libraryId.Value, libraryType: LibraryType.Music, contentLocations: [ROOT_PATH], - shouldSkipUnchangedDirectoriesDuringScan: shouldSkipUnchangedDirectoriesDuringScan); + shouldSkipUnchangedDirectoriesDuringScan: shouldSkipUnchangedDirectoriesDuringScan, + isContentOnSsd: isContentOnSsd); _mockLibraryRepository.GetByIdAsync(Arg.Any(), cancellationToken: Arg.Any()) .Returns(Result.From(library)); } diff --git a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/Common/MediaLibraryScanHashJobTests.cs b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/Common/MediaLibraryScanHashJobTests.cs index 8630e88d..3934edea 100644 --- a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/Common/MediaLibraryScanHashJobTests.cs +++ b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/Common/MediaLibraryScanHashJobTests.cs @@ -1,4 +1,5 @@ #region ========================================================================= USING ===================================================================================== +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.Models.DTO.MediaLibraryScanJobPayloads; @@ -13,6 +14,7 @@ using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggreg using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects; using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects; using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects; +using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.MediaLibraryScanJobPayloads; using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary; using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common; @@ -38,6 +40,7 @@ public class MediaLibraryScanHashJobTests private readonly IServiceScope _mockServiceScope; private readonly IServiceProvider _mockServiceProvider; private readonly IUnitOfWork _mockUnitOfWork; + private readonly ILibraryRepository _mockLibraryRepository; private readonly ILibraryScanStagingResultsRepository _mockStagingResultsRepository; private readonly IDomainEventPublisher _mockDomainEventPublisher; private readonly IFileHashService _mockFileHashService; @@ -46,6 +49,7 @@ public class MediaLibraryScanHashJobTests private readonly UserIdFixture _userIdFixture = new(); private readonly LibraryIdFixture _libraryIdFixture = new(); private readonly HashedFileSystemFileDtoFixture _hashedFileSystemFileDtoFixture = new(); + private readonly LibraryEntityFixture _libraryEntityFixture = new(); private readonly ScanId _scanId; private readonly UserId _userId; private readonly LibraryId _libraryId; @@ -63,7 +67,9 @@ public class MediaLibraryScanHashJobTests _mockUnitOfWork = Substitute.For(); _mockUnitOfWork.SaveChangesAsync(Arg.Any()).Returns(Result.Success); + _mockLibraryRepository = Substitute.For(); _mockStagingResultsRepository = Substitute.For(); + _mockUnitOfWork.LibraryRepository.Returns(_mockLibraryRepository); _mockUnitOfWork.LibraryScanStagingResultsRepository.Returns(_mockStagingResultsRepository); _mockServiceProvider.GetService(typeof(IUnitOfWork)).Returns(_mockUnitOfWork); @@ -84,6 +90,9 @@ public class MediaLibraryScanHashJobTests UserId = _userId, LibraryId = _libraryId }; + + _mockLibraryRepository.GetByIdAsync(_libraryId.Value, Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(Result.From(_libraryEntityFixture.Create(id: _libraryId.Value, userId: _userId.Value, isContentOnSsd: true))); } [Fact] @@ -97,7 +106,7 @@ public class MediaLibraryScanHashJobTests .Returns( Result.From>(filesToHash), Result.From>([])); - _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any>(), Arg.Any()) + _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()) .Returns(callInfo => Task.FromResult(callInfo.Arg>() .Select(file => file with { CurrentHash = 42UL }) .ToList())); @@ -111,6 +120,7 @@ public class MediaLibraryScanHashJobTests Assert.Equal(LibraryScanJobStatus.Completed, _sut.Status); await _mockFileHashService.Received(1).HashFilesAsync( Arg.Any>(), + Arg.Is(shouldParallelizeReads => shouldParallelizeReads), Arg.Any>(), Arg.Any()); await _mockStagingResultsRepository.Received(1).UpdateFileHashesAsync( @@ -120,6 +130,59 @@ public class MediaLibraryScanHashJobTests await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is(domainEvent => domainEvent.LibraryId == _libraryId), Arg.Any()); } + [Fact] + public async Task ExecuteAsync_WhenLibraryIsNotOnSsd_ShouldHashTheFilesSequentially() + { + // Arrange + _mockLibraryRepository.GetByIdAsync(_libraryId.Value, Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(Result.From(_libraryEntityFixture.Create(id: _libraryId.Value, userId: _userId.Value, isContentOnSsd: false))); + List filesToHash = [_hashedFileSystemFileDtoFixture.Create(path: "/books/book1.pdf")]; + _mockStagingResultsRepository.GetFilesToHashCountAsync(_scanId.Value, Arg.Any()) + .Returns(Result.From(1)); + _mockStagingResultsRepository.GetFilesToHashPageAsync(_scanId.Value, Arg.Any(), Arg.Any(), Arg.Any()) + .Returns( + Result.From>(filesToHash), + Result.From>([])); + _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()) + .Returns(callInfo => Task.FromResult(callInfo.Arg>() + .Select(file => file with { CurrentHash = 42UL }) + .ToList())); + _mockStagingResultsRepository.UpdateFileHashesAsync(_scanId.Value, Arg.Any>(), Arg.Any()) + .Returns(Result.From(Result.Updated)); + + // Act + await _sut.ExecuteAsync(Guid.NewGuid(), new { }, CancellationToken.None); + + // Assert + Assert.Equal(LibraryScanJobStatus.Completed, _sut.Status); + await _mockFileHashService.Received(1).HashFilesAsync( + Arg.Any>(), + Arg.Is(shouldParallelizeReads => !shouldParallelizeReads), + Arg.Any>(), + Arg.Any()); + } + + [Fact] + public async Task ExecuteAsync_WhenGettingTheLibraryFails_ShouldMarkJobAsFailedAndPublishFailureEvent() + { + // Arrange + _mockStagingResultsRepository.GetFilesToHashCountAsync(_scanId.Value, Arg.Any()) + .Returns(Result.From(1)); + _mockLibraryRepository.GetByIdAsync(_libraryId.Value, Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(Error.Failure("Database.Error", "Failed to retrieve the library")); + + // Act + await _sut.ExecuteAsync(Guid.NewGuid(), new { }, CancellationToken.None); + + // Assert + Assert.Equal(LibraryScanJobStatus.Failed, _sut.Status); + await _mockFileHashService.DidNotReceive().HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()); + await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is(domainEvent => + domainEvent.LibraryId == _libraryId + && domainEvent.MediaLibraryScanCompositeId.ScanId == _scanId + && domainEvent.MediaLibraryScanCompositeId.UserId == _userId), Arg.Any()); + } + [Fact] public async Task ExecuteAsync_WhenNoFilesNeedHashing_ShouldCompleteWithoutHashing() { @@ -134,7 +197,8 @@ public class MediaLibraryScanHashJobTests // Assert Assert.Equal(LibraryScanJobStatus.Completed, _sut.Status); - await _mockFileHashService.DidNotReceive().HashFilesAsync(Arg.Any>(), Arg.Any>(), Arg.Any()); + await _mockLibraryRepository.DidNotReceive().GetByIdAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()); + await _mockFileHashService.DidNotReceive().HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()); await _mockStagingResultsRepository.DidNotReceive().UpdateFileHashesAsync(Arg.Any(), Arg.Any>(), Arg.Any()); await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is(domainEvent => domainEvent.LibraryId == _libraryId), Arg.Any()); } @@ -151,7 +215,7 @@ public class MediaLibraryScanHashJobTests // Assert Assert.Equal(LibraryScanJobStatus.Failed, _sut.Status); - await _mockFileHashService.DidNotReceive().HashFilesAsync(Arg.Any>(), Arg.Any>(), Arg.Any()); + await _mockFileHashService.DidNotReceive().HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()); await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is(domainEvent => domainEvent.LibraryId == _libraryId && domainEvent.MediaLibraryScanCompositeId.ScanId == _scanId @@ -187,7 +251,7 @@ public class MediaLibraryScanHashJobTests // Assert Assert.Equal(LibraryScanJobStatus.Failed, _sut.Status); - await _mockFileHashService.DidNotReceive().HashFilesAsync(Arg.Any>(), Arg.Any>(), Arg.Any()); + await _mockFileHashService.DidNotReceive().HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()); await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is(domainEvent => domainEvent.LibraryId == _libraryId && domainEvent.MediaLibraryScanCompositeId.ScanId == _scanId @@ -205,7 +269,7 @@ public class MediaLibraryScanHashJobTests .Returns( Result.From>(filesToHash), Result.From>([])); - _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any>(), Arg.Any()) + _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()) .Returns(callInfo => Task.FromResult(callInfo.Arg>() .Select(file => file with { CurrentHash = 42UL }) .ToList())); @@ -217,7 +281,7 @@ public class MediaLibraryScanHashJobTests // Assert Assert.Equal(LibraryScanJobStatus.Failed, _sut.Status); - await _mockFileHashService.Received(1).HashFilesAsync(Arg.Any>(), Arg.Any>(), Arg.Any()); + await _mockFileHashService.Received(1).HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()); await _mockDomainEventPublisher.Received(1).PublishAsync(Arg.Is(domainEvent => domainEvent.LibraryId == _libraryId && domainEvent.MediaLibraryScanCompositeId.ScanId == _scanId @@ -235,7 +299,7 @@ public class MediaLibraryScanHashJobTests .Returns( Result.From>(filesToHash), Result.From>([])); - _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any>(), Arg.Any()) + _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()) .Returns(async callInfo => { await callInfo.Arg>()(); @@ -268,7 +332,7 @@ public class MediaLibraryScanHashJobTests .Returns( Result.From>(filesToHash), Result.From>([])); - _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any>(), Arg.Any()) + _mockFileHashService.HashFilesAsync(Arg.Any>(), Arg.Any(), Arg.Any>(), Arg.Any()) .Returns(async callInfo => { await Task.Delay(150); diff --git a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJobTests.cs b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJobTests.cs index 665e6cd0..c313f6f3 100644 --- a/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJobTests.cs +++ b/tests/UnitTests/Lumina.Infrastructure.UnitTests/Core/MediaLibrary/Management/Scanning/Jobs/WrittenContent/Books/BooksFileSystemDiscoveryJobTests.cs @@ -2,6 +2,7 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary; using Lumina.Application.Common.DataAccess.UoW; +using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Domain.Common.Errors; using Lumina.Domain.Common.Events; using Lumina.Domain.Common.Primitives; @@ -15,10 +16,13 @@ using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.U using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary; using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.WrittenContent.Books; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using NSubstitute; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; #endregion @@ -38,7 +42,9 @@ public class BooksFileSystemDiscoveryJobTests private readonly ILibraryRepository _mockLibraryRepository; private readonly ILibraryScanStagingResultsRepository _mockStagingResultsRepository; private readonly IDomainEventPublisher _mockDomainEventPublisher; + private readonly ILogger _mockLogger; private readonly BooksFileSystemDiscoveryJob _sut; + private readonly LibraryEntityFixture _libraryEntityFixture = new(); private readonly ScanIdFixture _scanIdFixture = new(); private readonly UserIdFixture _userIdFixture = new(); private readonly LibraryIdFixture _libraryIdFixture = new(); @@ -73,7 +79,9 @@ public class BooksFileSystemDiscoveryJobTests _scanId = _scanIdFixture.Create(); _userId = _userIdFixture.Create(); _libraryId = _libraryIdFixture.Create(); - _sut = new BooksFileSystemDiscoveryJob(_mockServiceScopeFactory) + _mockLogger = Substitute.For>(); + _mockLogger.IsEnabled(Arg.Any()).Returns(true); + _sut = new BooksFileSystemDiscoveryJob(_mockServiceScopeFactory, _mockLogger) { ScanId = _scanId, UserId = _userId, @@ -130,4 +138,82 @@ public class BooksFileSystemDiscoveryJobTests await Assert.ThrowsAnyAsync(() => operation); Assert.Equal(LibraryScanJobStatus.Canceled, _sut.Status); } + + [Fact] + public async Task ExecuteAsync_WhenTheLibraryIsOnSsd_ShouldLogThatTheFileSystemReadsRunInParallel() + { + // Arrange + string temporaryDirectoryPath = Path.Combine(Path.GetTempPath(), $"lumina-books-ssd-{Guid.NewGuid()}"); + Directory.CreateDirectory(temporaryDirectoryPath); + File.WriteAllText(Path.Combine(temporaryDirectoryPath, "book.pdf"), "book content"); + try + { + LibraryEntity libraryEntity = _libraryEntityFixture.Create( + id: _libraryId.Value, + userId: _userId.Value, + libraryType: LibraryType.Book, + contentLocations: [temporaryDirectoryPath], + isContentOnSsd: true); + _mockLibraryRepository.GetByIdAsync(_libraryId.Value, cancellationToken: Arg.Any()) + .Returns(Result.From(libraryEntity)); + _mockStagingResultsRepository.InsertRangeAsync(Arg.Any>(), Arg.Any()) + .Returns(Result.From(Result.Created)); + + // Act + await _sut.ExecuteAsync(Guid.NewGuid(), new { }, CancellationToken.None); + + // Assert + Assert.Equal(LibraryScanJobStatus.Completed, _sut.Status); + await _mockStagingResultsRepository.Received(1).InsertRangeAsync( + Arg.Is>(entities => entities.Count == 1 && Path.GetFileName(entities.First().Path) == "book.pdf"), + Arg.Any()); + _mockLogger.Received(1).Log( + LogLevel.Debug, + Arg.Any(), + Arg.Is(state => state.ToString()!.Contains("solid state drive", StringComparison.Ordinal)), + Arg.Any(), + Arg.Any>()); + } + finally + { + Directory.Delete(temporaryDirectoryPath, recursive: true); + } + } + + [Fact] + public async Task StageFilesInParallelAsync_WhenAFileVanishesBeforeItsMetadataIsRead_ShouldSkipItAndLogAWarning() + { + // Arrange + FileInfo vanishedFile = new(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString(), "vanished.pdf")); + List stagingBatch = []; + + // Act + await _sut.StageFilesInParallelAsync([vanishedFile], stagingBatch, _mockStagingResultsRepository, CancellationToken.None); + + // Assert + Assert.Empty(stagingBatch); + await _mockStagingResultsRepository.DidNotReceive().InsertRangeAsync(Arg.Any>(), Arg.Any()); + _mockLogger.Received(1).Log( + LogLevel.Warning, + Arg.Any(), + Arg.Is(state => state.ToString()!.Contains("vanished.pdf", StringComparison.Ordinal)), + Arg.Any(), + Arg.Any>()); + } + + [Fact] + public async Task StageFilesInParallelAsync_WhenAFileReadThrowsAnUnexpectedException_ShouldRethrowTheRealCause() + { + // Arrange + List stagingBatch = []; + List files = [null!]; + + // Act + Exception exception = await Assert.ThrowsAsync(() => + _sut.StageFilesInParallelAsync(files, stagingBatch, _mockStagingResultsRepository, CancellationToken.None)); + + // Assert + // Parallel.For wraps the body exception in an AggregateException, which would otherwise be reported as "One or more errors occurred.". + Assert.IsType(exception); + } } diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointTests.cs index c9712bca..6c2f6de8 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointTests.cs @@ -87,6 +87,7 @@ public class AddLibraryEndpointTests { // Arrange AddLibraryRequest request = _addLibraryRequestFixture.Create( + isContentOnSsd: true, shouldTrackConsumptionProgress: true, completionThresholdPercentage: 65); CancellationToken cancellationToken = CancellationToken.None; @@ -108,6 +109,7 @@ public class AddLibraryEndpointTests command.CanDownloadMetadataFromWeb == request.CanDownloadMetadataFromWeb && command.ShouldSaveMetadataInMediaDirectories == request.ShouldSaveMetadataInMediaDirectories && command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan && + command.IsContentOnSsd == request.IsContentOnSsd && command.ShouldTrackConsumptionProgress == request.ShouldTrackConsumptionProgress && command.CompletionThresholdPercentage == request.CompletionThresholdPercentage), Arg.Is(cancellationToken)); diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointTests.cs index dd90a0f8..ee1570b5 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointTests.cs @@ -87,6 +87,7 @@ public class UpdateLibraryEndpointTests { // Arrange UpdateLibraryRequest request = _updateLibraryRequestFixture.Create( + isContentOnSsd: true, shouldTrackConsumptionProgress: true, completionThresholdPercentage: 65); CancellationToken cancellationToken = CancellationToken.None; @@ -110,6 +111,7 @@ public class UpdateLibraryEndpointTests command.CanDownloadMetadataFromWeb == request.CanDownloadMetadataFromWeb && command.ShouldSaveMetadataInMediaDirectories == request.ShouldSaveMetadataInMediaDirectories && command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan && + command.IsContentOnSsd == request.IsContentOnSsd && command.ShouldTrackConsumptionProgress == request.ShouldTrackConsumptionProgress && command.CompletionThresholdPercentage == request.CompletionThresholdPercentage), Arg.Is(cancellationToken));