Skip to content

Commit

Permalink
Allow removal of all people from an item
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowghost committed May 21, 2024
1 parent e67eb48 commit 8a5a93e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Emby.Server.Implementations/Data/SqliteItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5222,19 +5222,20 @@ public void UpdatePeople(Guid itemId, List<PersonInfo> people)
throw new ArgumentNullException(nameof(itemId));
}

ArgumentNullException.ThrowIfNull(people);

CheckDisposed();

using var connection = GetConnection();
using var transaction = connection.BeginTransaction();
// First delete chapters
// Delete all existing people first
using var command = connection.CreateCommand();
command.CommandText = "delete from People where ItemId=@ItemId";
command.TryBind("@ItemId", itemId);
command.ExecuteNonQuery();

InsertPeople(itemId, people, connection);
if (people is not null)
{
InsertPeople(itemId, people, connection);
}

transaction.Commit();
}
Expand Down
6 changes: 4 additions & 2 deletions Emby.Server.Implementations/Library/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2812,8 +2812,10 @@ public async Task UpdatePeopleAsync(BaseItem item, List<PersonInfo> people, Canc
}

_itemRepository.UpdatePeople(item.Id, people);

await SavePeopleMetadataAsync(people, cancellationToken).ConfigureAwait(false);
if (people is not null)
{
await SavePeopleMetadataAsync(people, cancellationToken).ConfigureAwait(false);
}
}

public async Task<ItemImageInfo> ConvertImageToLocal(BaseItem item, ItemImageInfo image, int imageIndex, bool removeOnFailure)
Expand Down

0 comments on commit 8a5a93e

Please sign in to comment.