|
|
|
@ -4716,72 +4716,6 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
|
|
|
|
|
public void UpdateInheritedValues(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
UpdateInheritedTags(cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateInheritedTags(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var newValues = new List<Tuple<Guid, string[]>>();
|
|
|
|
|
|
|
|
|
|
var commandText = @"select guid,
|
|
|
|
|
(select group_concat(Value, '|') from ItemValues where (ItemValues.ItemId = Outer.Guid OR ItemValues.ItemId in ((Select AncestorId from AncestorIds where AncestorIds.ItemId=Outer.guid))) and ItemValues.Type = 4) NewInheritedTags,
|
|
|
|
|
(select group_concat(Value, '|') from ItemValues where ItemValues.ItemId = Outer.Guid and ItemValues.Type = 6) CurrentInheritedTags
|
|
|
|
|
from typedbaseitems as Outer
|
|
|
|
|
where (NewInheritedTags <> CurrentInheritedTags or (NewInheritedTags is null) <> (CurrentInheritedTags is null))
|
|
|
|
|
limit 100";
|
|
|
|
|
|
|
|
|
|
using (WriteLock.Write())
|
|
|
|
|
{
|
|
|
|
|
using (var connection = CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
connection.RunInTransaction(db =>
|
|
|
|
|
{
|
|
|
|
|
foreach (var row in connection.Query(commandText))
|
|
|
|
|
{
|
|
|
|
|
var id = row.GetGuid(0);
|
|
|
|
|
string value = row.IsDBNull(1) ? null : row.GetString(1);
|
|
|
|
|
|
|
|
|
|
var valuesArray = string.IsNullOrWhiteSpace(value) ? new string[] { } : value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
newValues.Add(new Tuple<Guid, string[]>(id, valuesArray));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.Debug("UpdateInheritedTags - {0} rows", newValues.Count);
|
|
|
|
|
if (newValues.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var insertStatement = PrepareStatement(connection, "insert into ItemValues (ItemId, Type, Value, CleanValue) values (@ItemId, 6, @Value, @CleanValue)"))
|
|
|
|
|
{
|
|
|
|
|
using (var deleteStatement = PrepareStatement(connection, "delete from ItemValues where ItemId=@ItemId and Type=6"))
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in newValues)
|
|
|
|
|
{
|
|
|
|
|
var guidBlob = item.Item1.ToGuidBlob();
|
|
|
|
|
|
|
|
|
|
deleteStatement.Reset();
|
|
|
|
|
deleteStatement.TryBind("@ItemId", guidBlob);
|
|
|
|
|
deleteStatement.MoveNext();
|
|
|
|
|
|
|
|
|
|
foreach (var itemValue in item.Item2)
|
|
|
|
|
{
|
|
|
|
|
insertStatement.Reset();
|
|
|
|
|
|
|
|
|
|
insertStatement.TryBind("@ItemId", guidBlob);
|
|
|
|
|
insertStatement.TryBind("@Value", itemValue);
|
|
|
|
|
|
|
|
|
|
insertStatement.TryBind("@CleanValue", GetCleanValue(itemValue));
|
|
|
|
|
|
|
|
|
|
insertStatement.MoveNext();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}, TransactionMode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Dictionary<string, string[]> GetTypeMapDictionary()
|
|
|
|
|