Refactor ReattachUserData methods to be asynchronous
This commit is contained in:
@@ -2203,9 +2203,9 @@ namespace Emby.Server.Implementations.Library
|
|||||||
=> UpdateItemsAsync([item], parent, updateReason, cancellationToken);
|
=> UpdateItemsAsync([item], parent, updateReason, cancellationToken);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void ReattachUserData(BaseItem item, CancellationToken cancellationToken)
|
public async Task ReattachUserDataAsync(BaseItem item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_itemRepository.ReattachUserData(item, cancellationToken);
|
await _itemRepository.ReattachUserDataAsync(item, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RunMetadataSavers(BaseItem item, ItemUpdateType updateReason)
|
public async Task RunMetadataSavers(BaseItem item, ItemUpdateType updateReason)
|
||||||
|
|||||||
@@ -746,7 +746,7 @@ public sealed class BaseItemRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void ReattachUserData(BaseItemDto item, CancellationToken cancellationToken)
|
public async Task ReattachUserDataAsync(BaseItemDto item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(item);
|
ArgumentNullException.ThrowIfNull(item);
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
@@ -755,12 +755,14 @@ public sealed class BaseItemRepository
|
|||||||
|
|
||||||
var userKeys = item.GetUserDataKeys().ToArray();
|
var userKeys = item.GetUserDataKeys().ToArray();
|
||||||
var retentionDate = (DateTime?)null;
|
var retentionDate = (DateTime?)null;
|
||||||
context.UserData
|
await context.UserData
|
||||||
.Where(e => e.ItemId == PlaceholderId)
|
.Where(e => e.ItemId == PlaceholderId)
|
||||||
.Where(e => userKeys.Contains(e.CustomDataKey))
|
.Where(e => userKeys.Contains(e.CustomDataKey))
|
||||||
.ExecuteUpdate(e => e
|
.ExecuteUpdateAsync(
|
||||||
|
e => e
|
||||||
.SetProperty(f => f.ItemId, item.Id)
|
.SetProperty(f => f.ItemId, item.Id)
|
||||||
.SetProperty(f => f.RetentionDate, retentionDate));
|
.SetProperty(f => f.RetentionDate, retentionDate),
|
||||||
|
cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -2053,7 +2053,8 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
public virtual async Task UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationToken)
|
public virtual async Task UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationToken)
|
||||||
=> await LibraryManager.UpdateItemAsync(this, GetParent(), updateReason, cancellationToken).ConfigureAwait(false);
|
=> await LibraryManager.UpdateItemAsync(this, GetParent(), updateReason, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
public void ReattachUserData(CancellationToken cancellationToken) => LibraryManager.ReattachUserData(this, cancellationToken);
|
public async Task ReattachUserDataAsync(CancellationToken cancellationToken) =>
|
||||||
|
await LibraryManager.ReattachUserDataAsync(this, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates that images within the item are still on the filesystem.
|
/// Validates that images within the item are still on the filesystem.
|
||||||
|
|||||||
@@ -286,7 +286,8 @@ namespace MediaBrowser.Controller.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
void ReattachUserData(BaseItem item, CancellationToken cancellationToken);
|
/// <returns>A task that represents the asynchronous reattachment operation.</returns>
|
||||||
|
Task ReattachUserDataAsync(BaseItem item, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the item.
|
/// Retrieves the item.
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ public interface IItemRepository
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
void ReattachUserData(BaseItem item, CancellationToken cancellationToken);
|
/// <returns>A task that represents the asynchronous reattachment operation.</returns>
|
||||||
|
Task ReattachUserDataAsync(BaseItem item, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the item.
|
/// Retrieves the item.
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
await result.Item.UpdateToRepositoryAsync(reason, cancellationToken).ConfigureAwait(false);
|
await result.Item.UpdateToRepositoryAsync(reason, cancellationToken).ConfigureAwait(false);
|
||||||
if (reattachUserData)
|
if (reattachUserData)
|
||||||
{
|
{
|
||||||
result.Item.ReattachUserData(cancellationToken);
|
await result.Item.ReattachUserDataAsync(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.Item.SupportsPeople && result.People is not null)
|
if (result.Item.SupportsPeople && result.People is not null)
|
||||||
|
|||||||
Reference in New Issue
Block a user