mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 21:11:10 +00:00
Serializes media library scans through a scan queue
Replaces the job queue with a scan queue that executes one media library scan at a time, in the order in which the scans were queued, so several libraries requested at once no longer run one complete job chain each on the thread pool shared with the web server. Keeps queued scans Pending and cancellable, reports them as queued, and cancels the executing scan and the queued ones when the user cancels all scans. A media library type without a scanner now fails its own scan instead of leaving it stuck Pending, without stopping the scans queued behind it. Makes the file system discovery job the only top level job of a scan graph, so awaiting it completes the whole scan, and leaves one logical processor free for the rest of the process while discovery and hashing read files in parallel. Removes the per job Task.Run wrappers, links the scan cancellation with the host shutdown token in the scan processor, updates the ADR amendments, API documentation, manual, web client and tests, and normalizes the comments of the touched files.
This commit is contained in:
1 parent
b0c24a1722
commit
8ff5149b6e
85 files changed
+2559
-1394
No files matched your search
+9
-6
@@ -123,22 +123,25 @@ public class LibraryScanRepositoryTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetRunningScansAsync_WhenCalled_ShouldReturnOnlyRunningScans()
|
||||
public async Task GetActiveScansAsync_WhenCalled_ShouldReturnPendingAndRunningScansOnly()
|
||||
{
|
||||
// Arrange
|
||||
LibraryScanEntity runningScan = _libraryScanEntityFixture.Create(status: LibraryScanJobStatus.Running);
|
||||
LibraryScanEntity completedScan = _libraryScanEntityFixture.Create(status: LibraryScanJobStatus.Completed);
|
||||
LibraryScanEntity pendingScan = _libraryScanEntityFixture.Create(status: LibraryScanJobStatus.Pending);
|
||||
_mockContext.LibraryScans.AddRange(runningScan, completedScan, pendingScan);
|
||||
LibraryScanEntity completedScan = _libraryScanEntityFixture.Create(status: LibraryScanJobStatus.Completed);
|
||||
LibraryScanEntity canceledScan = _libraryScanEntityFixture.Create(status: LibraryScanJobStatus.Canceled);
|
||||
LibraryScanEntity failedScan = _libraryScanEntityFixture.Create(status: LibraryScanJobStatus.Failed);
|
||||
_mockContext.LibraryScans.AddRange(runningScan, pendingScan, completedScan, canceledScan, failedScan);
|
||||
await _mockContext.SaveChangesAsync();
|
||||
|
||||
// Act
|
||||
Result<IEnumerable<LibraryScanEntity>> result = await _sut.GetRunningScansAsync(CancellationToken.None);
|
||||
Result<IEnumerable<LibraryScanEntity>> result = await _sut.GetActiveScansAsync(CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
Assert.False(result.IsFailure);
|
||||
LibraryScanEntity retrievedScan = Assert.Single(result.Value);
|
||||
Assert.Equal(runningScan.Id, retrievedScan.Id);
|
||||
Assert.Equal(2, result.Value.Count());
|
||||
Assert.Contains(result.Value, libraryScan => libraryScan.Id == runningScan.Id);
|
||||
Assert.Contains(result.Value, libraryScan => libraryScan.Id == pendingScan.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in new issue
Block a user