mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Made Clean task async
This commit is contained in:
parent
e331dc35ac
commit
447ff1d23c
@ -30,11 +30,10 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
CleanDeadItems(cancellationToken, progress);
|
return CleanDeadItems(cancellationToken, progress);
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CleanDeadItems(CancellationToken cancellationToken, IProgress<double> progress)
|
private async Task CleanDeadItems(CancellationToken cancellationToken, IProgress<double> progress)
|
||||||
{
|
{
|
||||||
var itemIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
var itemIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
||||||
{
|
{
|
||||||
@ -68,10 +67,10 @@ namespace Emby.Server.Implementations.Data
|
|||||||
progress.Report(percent * 100);
|
progress.Report(percent * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
using var context = _dbProvider.CreateDbContext();
|
using var context = await _dbProvider.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
|
||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = await context.Database.BeginTransactionAsync(cancellationToken).ConfigureAwait(false);
|
||||||
context.ItemValues.Where(e => e.BaseItemsMap!.Count == 0).ExecuteDelete();
|
await context.ItemValues.Where(e => e.BaseItemsMap!.Count == 0).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false);
|
||||||
transaction.Commit();
|
await transaction.CommitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user