fix(410): log scan cancellation below ERROR (user-initiated, not a failure) (#453)
Build ErsatzTV Image / CI image pin matches docker/ci (push) Has been skipped
Build ErsatzTV Image / Docs update reminder (push) Has been skipped
Build ErsatzTV Image / decisions.md append-only (push) Has been skipped
Build ErsatzTV Image / Build & test (.NET) (push) Has started running
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Has been cancelled
Build ErsatzTV Image / Functional E2E (curl contracts) (push) Has been cancelled
Build ErsatzTV Image / Build & push image (amd64) (push) Has been cancelled
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (push) Has been cancelled
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (push) Has been cancelled

Co-authored-by: Timothy <timothy.look@gmail.com>
Co-committed-by: Timothy <timothy.look@gmail.com>
This commit was merged in pull request #453.
This commit is contained in:
2026-07-18 16:18:02 +00:00
committed by timothy
parent ab8e5d7a91
commit ebb9a40dc3
6 changed files with 148 additions and 10 deletions
@@ -1,5 +1,6 @@
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Errors;
using ErsatzTV.Core.Interfaces.Repositories;
using ErsatzTV.Scanner.Application.MediaSources;
using ErsatzTV.Scanner.Core.Interfaces;
@@ -96,6 +97,27 @@ public class ScanLocalLibraryHandlerTests
ShouldHaveLogged("Error scanning local library path /movies: scan failed");
}
[Test]
public async Task Should_Not_Log_Error_When_A_Path_Scan_Is_Canceled()
{
ScanResult(Left<BaseError, Unit>(new ScanCanceled()));
await Handler().Handle(
new ScanLocalLibrary("http://ersatztv.example", _library.Id, true),
CancellationToken.None);
// a user-initiated cancellation is not a failure and must not be logged at ERROR (#410);
// it's still correctly excluded from the "last scan" stamp, same as any other failure
_library.LastScan.ShouldBeNull();
await _libraryRepository.DidNotReceive().UpdateLastScan(Arg.Any<Library>());
_logger.ReceivedCalls()
.Any(call => call.GetArguments().ElementAtOrDefault(2)?.ToString()
== "Error scanning local library path /movies: Scan was canceled")
.ShouldBeFalse();
ShouldHaveLogged("Scan of local library path /movies was canceled");
}
[Test]
public async Task Should_Not_Set_Library_LastScan_When_A_Later_Path_Fails()
{