From 6377e7365b94be92e38515beda20a0e6dbabe65f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 26 Aug 2016 13:24:04 -0400 Subject: fix sync container statuses --- .../Persistence/SqliteItemRepository.cs | 92 ++-------------------- 1 file changed, 8 insertions(+), 84 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs') diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 5c94d589dc..dc98c346ed 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -92,7 +92,6 @@ namespace MediaBrowser.Server.Implementations.Persistence private IDbCommand _deleteImagesCommand; private IDbCommand _saveImagesCommand; - private IDbCommand _updateInheritedRatingCommand; private IDbCommand _updateInheritedTagsCommand; public const int LatestSchemaVersion = 109; @@ -412,7 +411,8 @@ namespace MediaBrowser.Server.Implementations.Persistence "SeasonId", "SeriesId", "SeriesSortName", - "PresentationUniqueKey" + "PresentationUniqueKey", + "InheritedParentalRatingValue" }; private readonly string[] _mediaStreamSaveColumns = @@ -611,11 +611,6 @@ namespace MediaBrowser.Server.Implementations.Persistence _saveStreamCommand.Parameters.Add(_saveStreamCommand, "@" + col); } - _updateInheritedRatingCommand = _connection.CreateCommand(); - _updateInheritedRatingCommand.CommandText = "Update TypedBaseItems set InheritedParentalRatingValue=@InheritedParentalRatingValue where Guid=@Guid"; - _updateInheritedRatingCommand.Parameters.Add(_updateInheritedRatingCommand, "@Guid"); - _updateInheritedRatingCommand.Parameters.Add(_updateInheritedRatingCommand, "@InheritedParentalRatingValue"); - _updateInheritedTagsCommand = _connection.CreateCommand(); _updateInheritedTagsCommand.CommandText = "Update TypedBaseItems set InheritedTags=@InheritedTags where Guid=@Guid"; _updateInheritedTagsCommand.Parameters.Add(_updateInheritedTagsCommand, "@Guid"); @@ -1458,6 +1453,12 @@ namespace MediaBrowser.Server.Implementations.Persistence } index++; + if (!reader.IsDBNull(index)) + { + item.InheritedParentalRatingValue = reader.GetInt32(index); + } + index++; + return item; } @@ -3402,7 +3403,6 @@ namespace MediaBrowser.Server.Implementations.Persistence public async Task UpdateInheritedValues(CancellationToken cancellationToken) { - await UpdateInheritedParentalRating(cancellationToken).ConfigureAwait(false); await UpdateInheritedTags(cancellationToken).ConfigureAwait(false); } @@ -3482,82 +3482,6 @@ namespace MediaBrowser.Server.Implementations.Persistence } } - private async Task UpdateInheritedParentalRating(CancellationToken cancellationToken) - { - var newValues = new List>(); - - using (var cmd = _connection.CreateCommand()) - { - cmd.CommandText = "select Guid,InheritedParentalRatingValue,(select Max(InheritedParentalRatingValue, (select COALESCE(MAX(InheritedParentalRatingValue),0) from TypedBaseItems where guid in (Select AncestorId from AncestorIds where ItemId=Outer.guid)))) as NewInheritedParentalRatingValue from typedbaseitems as Outer where InheritedParentalRatingValue <> NewInheritedParentalRatingValue"; - - using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)) - { - while (reader.Read()) - { - var id = reader.GetGuid(0); - var newValue = reader.GetInt32(2); - - newValues.Add(new Tuple(id, newValue)); - } - } - } - - Logger.Debug("UpdateInheritedParentalRatings - {0} rows", newValues.Count); - if (newValues.Count == 0) - { - return; - } - - await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false); - - IDbTransaction transaction = null; - - try - { - transaction = _connection.BeginTransaction(); - - foreach (var item in newValues) - { - _updateInheritedRatingCommand.GetParameter(0).Value = item.Item1; - _updateInheritedRatingCommand.GetParameter(1).Value = item.Item2; - - _updateInheritedRatingCommand.Transaction = transaction; - _updateInheritedRatingCommand.ExecuteNonQuery(); - } - - transaction.Commit(); - } - catch (OperationCanceledException) - { - if (transaction != null) - { - transaction.Rollback(); - } - - throw; - } - catch (Exception e) - { - Logger.ErrorException("Error running query:", e); - - if (transaction != null) - { - transaction.Rollback(); - } - - throw; - } - finally - { - if (transaction != null) - { - transaction.Dispose(); - } - - WriteLock.Release(); - } - } - private static Dictionary GetTypeMapDictionary() { var dict = new Dictionary(StringComparer.OrdinalIgnoreCase); -- cgit v1.2.3 From 73bafa7cda7d341a347b4f56681d7efebe756618 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 27 Aug 2016 12:47:09 -0400 Subject: fix saving of IsVirtualItem --- MediaBrowser.Server.Implementations/Library/UserViewManager.cs | 2 +- MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs') diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index 319e715c33..5fffa3d1fb 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -283,7 +283,7 @@ namespace MediaBrowser.Server.Implementations.Library ExcludeItemTypes = excludeItemTypes, ExcludeLocationTypes = new[] { LocationType.Virtual }, Limit = limit * 5, - ExcludeSourceTypes = parentIds.Length == 0 ? new[] { SourceType.Channel, SourceType.LiveTV } : new SourceType[] { }, + SourceTypes = parentIds.Length == 0 ? new[] { SourceType.Library } : new SourceType[] { }, IsPlayed = request.IsPlayed }, parentIds); diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index dc98c346ed..5ece3dd826 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -937,7 +937,7 @@ namespace MediaBrowser.Server.Implementations.Persistence _saveItemCommand.GetParameter(index++).Value = item.Album; - _saveItemCommand.GetParameter(index++).Value = item.IsVirtualItem || (!item.IsFolder && item.LocationType == LocationType.Virtual); + _saveItemCommand.GetParameter(index++).Value = item.IsVirtualItem; var hasSeries = item as IHasSeries; if (hasSeries != null) -- cgit v1.2.3