Skip to content

Commit 0770813

Browse files
Quiklerclaude
andcommitted
refactor: Remove CancellationToken from IDownloadHistoryRepository
Dapper.AOT doesn't intercept CommandDefinition overloads yet, so CancellationToken cannot be passed to Dapper queries in trimmed builds. Tracking: DapperLib/DapperAOT#153 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a5e8dac commit 0770813

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

QuikytLoader.Application/Interfaces/Repositories/IDownloadHistoryRepository.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ namespace QuikytLoader.Application.Interfaces.Repositories;
66
/// <summary>
77
/// Repository for download history persistence
88
/// </summary>
9+
/// <remarks>
10+
/// CancellationToken not supported - Dapper.AOT doesn't intercept CommandDefinition yet.
11+
/// Tracking: https://github.com/DapperLib/DapperAOT/pull/153
12+
/// </remarks>
913
public interface IDownloadHistoryRepository
1014
{
1115
/// <summary>
1216
/// Upserts a download history record. Inserts new record or updates existing record if YouTubeId already exists.
1317
/// </summary>
14-
Task UpsertAsync(DownloadHistoryEntity downloadEntity, CancellationToken cancellationToken = default);
18+
Task UpsertAsync(DownloadHistoryEntity downloadEntity);
1519

1620
/// <summary>
1721
/// Gets a download record by YouTube ID.
1822
/// </summary>
19-
Task<DownloadHistoryEntity?> GetByIdAsync(YouTubeId id, CancellationToken cancellationToken = default);
23+
Task<DownloadHistoryEntity?> GetByIdAsync(YouTubeId id);
2024
}

QuikytLoader.Application/UseCases/DownloadAndSendUseCase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ await historyRepo.UpsertAsync(
4747
new DownloadHistoryEntity(
4848
entity.YouTubeId,
4949
customTitle ?? entity.VideoTitle,
50-
DateTime.UtcNow.ToString("o")),
51-
cancellationToken);
50+
DateTime.UtcNow.ToString("o")));
5251

5352
// 5. Map domain entity to DTO and return
5453
var dto = new DownloadResultDto(entity.YouTubeId.Id, entity.VideoTitle, entity.TempMediaFilePath, entity.TempThumbnailPath);

QuikytLoader.Application/UseCases/FindExistingDownloadUseCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class FindExistingDownloadUseCase(
1818
if (!youtubeIdResult.IsSuccess)
1919
return Result<DownloadHistoryDto?>.Failure(youtubeIdResult.Error);
2020

21-
var downloadEntity = await historyRepo.GetByIdAsync(youtubeIdResult.Value, cancellationToken);
21+
var downloadEntity = await historyRepo.GetByIdAsync(youtubeIdResult.Value);
2222
if (downloadEntity is null)
2323
return Result<DownloadHistoryDto?>.Success(null);
2424

QuikytLoader.Infrastructure/Persistence/Repositories/DownloadHistoryRepository.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ namespace QuikytLoader.Infrastructure.Persistence.Repositories;
88

99
/// <summary>
1010
/// Repository for managing download history using SQLite database with Dapper ORM.
11-
/// Uses simple Dapper overloads (not CommandDefinition) for Dapper.AOT compatibility.
1211
/// </summary>
12+
/// <remarks>
13+
/// CancellationToken not supported in Dapper queries - Dapper.AOT doesn't intercept CommandDefinition yet.
14+
/// Tracking: https://github.com/DapperLib/DapperAOT/pull/153
15+
/// </remarks>
1316
internal class DownloadHistoryRepository(IDbConnectionFactory dbConnectionFactory) : IDownloadHistoryRepository
1417
{
15-
public async Task UpsertAsync(DownloadHistoryEntity downloadEntity, CancellationToken cancellationToken = default)
18+
public async Task UpsertAsync(DownloadHistoryEntity downloadEntity)
1619
{
17-
await using var connection = await dbConnectionFactory.GetConnectionAsync(cancellationToken);
20+
await using var connection = await dbConnectionFactory.GetConnectionAsync();
1821
const string upsertSql = """
1922
INSERT OR REPLACE INTO DownloadHistory (YouTubeId, VideoTitle, DownloadedAt)
2023
VALUES (@YouTubeId, @VideoTitle, @DownloadedAt)
@@ -28,9 +31,9 @@ INSERT OR REPLACE INTO DownloadHistory (YouTubeId, VideoTitle, DownloadedAt)
2831
});
2932
}
3033

31-
public async Task<DownloadHistoryEntity?> GetByIdAsync(YouTubeId id, CancellationToken cancellationToken = default)
34+
public async Task<DownloadHistoryEntity?> GetByIdAsync(YouTubeId id)
3235
{
33-
await using var connection = await dbConnectionFactory.GetConnectionAsync(cancellationToken);
36+
await using var connection = await dbConnectionFactory.GetConnectionAsync();
3437
const string query = """
3538
SELECT YouTubeId, VideoTitle, DownloadedAt
3639
FROM DownloadHistory

0 commit comments

Comments
 (0)