From fd261cecf75dc6e5f9e617578e7c648477eb74a5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 16 Apr 2015 23:31:19 -0400 Subject: [PATCH] resolve photo scan hang --- .../UserLibrary/PlaystateService.cs | 12 ++++++ MediaBrowser.Controller/Entities/BaseItem.cs | 4 +- MediaBrowser.Controller/Entities/Folder.cs | 18 ++++----- .../Providers/MetadataStatus.cs | 40 ------------------- MediaBrowser.Dlna/PlayTo/PlayToManager.cs | 2 +- MediaBrowser.Model/Dto/UserItemDataDto.cs | 6 +++ .../Session/ClientCapabilities.cs | 4 +- .../Manager/MetadataService.cs | 2 - .../EntryPoints/UserDataChangeNotifier.cs | 9 ++++- .../Library/UserViewManager.cs | 3 +- .../SqliteProviderInfoRepository.cs | 14 ++----- .../Photos/PhotoAlbumImageProvider.cs | 24 +++++------ 12 files changed, 55 insertions(+), 83 deletions(-) diff --git a/MediaBrowser.Api/UserLibrary/PlaystateService.cs b/MediaBrowser.Api/UserLibrary/PlaystateService.cs index 4661abf4c..f66f307db 100644 --- a/MediaBrowser.Api/UserLibrary/PlaystateService.cs +++ b/MediaBrowser.Api/UserLibrary/PlaystateService.cs @@ -67,6 +67,13 @@ namespace MediaBrowser.Api.UserLibrary { } + [Route("/Sessions/Playing/Ping", "POST", Summary = "Pings a playback session")] + public class PingPlaybackSession : IReturnVoid + { + [ApiMember(Name = "PlaySessionId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] + public string PlaySessionId { get; set; } + } + [Route("/Sessions/Playing/Stopped", "POST", Summary = "Reports playback has stopped within a session")] public class ReportPlaybackStopped : PlaybackStopInfo, IReturnVoid { @@ -336,6 +343,11 @@ namespace MediaBrowser.Api.UserLibrary Task.WaitAll(task); } + public void Post(PingPlaybackSession request) + { + ApiEntryPoint.Instance.PingTranscodingJob(request.PlaySessionId); + } + /// /// Posts the specified request. /// diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 10fa4adad..73ede8179 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1,5 +1,4 @@ -using System.Globalization; -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Collections; @@ -18,6 +17,7 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Model.Users; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Runtime.Serialization; diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 975f3e394..821e6b5ca 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -164,18 +164,22 @@ namespace MediaBrowser.Controller.Entities protected void AddChildrenInternal(IEnumerable children) { + var actualChildren = ActualChildren; + lock (_childrenSyncLock) { - var newChildren = ActualChildren.ToList(); + var newChildren = actualChildren.ToList(); newChildren.AddRange(children); _children = newChildren; } } protected void AddChildInternal(BaseItem child) { + var actualChildren = ActualChildren; + lock (_childrenSyncLock) { - var newChildren = ActualChildren.ToList(); + var newChildren = actualChildren.ToList(); newChildren.Add(child); _children = newChildren; } @@ -184,10 +188,11 @@ namespace MediaBrowser.Controller.Entities protected void RemoveChildrenInternal(IEnumerable children) { var ids = children.Select(i => i.Id).ToList(); + var actualChildren = ActualChildren; lock (_childrenSyncLock) { - _children = ActualChildren.Where(i => !ids.Contains(i.Id)).ToList(); + _children = actualChildren.Where(i => !ids.Contains(i.Id)).ToList(); } } @@ -302,7 +307,7 @@ namespace MediaBrowser.Controller.Entities { if (_children == null) { - _children = LoadChildrenInternal(); + _children = LoadChildren().ToList(); } } } @@ -356,11 +361,6 @@ namespace MediaBrowser.Controller.Entities return base.IsVisible(user); } - private List LoadChildrenInternal() - { - return LoadChildren().ToList(); - } - /// /// Loads our children. Validation will occur externally. /// We want this sychronous. diff --git a/MediaBrowser.Controller/Providers/MetadataStatus.cs b/MediaBrowser.Controller/Providers/MetadataStatus.cs index 12844c3c4..283b9edbc 100644 --- a/MediaBrowser.Controller/Providers/MetadataStatus.cs +++ b/MediaBrowser.Controller/Providers/MetadataStatus.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Controller.Providers { @@ -54,13 +52,6 @@ namespace MediaBrowser.Controller.Providers /// The last result error message. public string LastErrorMessage { get; set; } - /// - /// Gets or sets the providers refreshed. - /// - /// The providers refreshed. - public List MetadataProvidersRefreshed { get; set; } - public List ImageProvidersRefreshed { get; set; } - public DateTime? ItemDateModified { get; set; } public void AddStatus(ProviderRefreshStatus status, string errorMessage) @@ -83,9 +74,6 @@ namespace MediaBrowser.Controller.Providers public MetadataStatus() { LastStatus = ProviderRefreshStatus.Success; - - MetadataProvidersRefreshed = new List(); - ImageProvidersRefreshed = new List(); } public bool IsDirty { get; private set; } @@ -109,33 +97,5 @@ namespace MediaBrowser.Controller.Providers DateLastImagesRefresh = date; } - - public void AddImageProvidersRefreshed(List providerIds) - { - var count = ImageProvidersRefreshed.Count; - - providerIds.AddRange(ImageProvidersRefreshed); - - ImageProvidersRefreshed = providerIds.Distinct().ToList(); - - if (ImageProvidersRefreshed.Count != count) - { - IsDirty = true; - } - } - - public void AddMetadataProvidersRefreshed(List providerIds) - { - var count = MetadataProvidersRefreshed.Count; - - providerIds.AddRange(MetadataProvidersRefreshed); - - MetadataProvidersRefreshed = providerIds.Distinct().ToList(); - - if (MetadataProvidersRefreshed.Count != count) - { - IsDirty = true; - } - } } } diff --git a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs index ba6d656dd..77c98f9b9 100644 --- a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs +++ b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs @@ -114,7 +114,7 @@ namespace MediaBrowser.Dlna.PlayTo _mediaSourceManager); controller.Init(device); - + var profile = _dlnaManager.GetProfile(device.Properties.ToDeviceIdentification()) ?? _dlnaManager.GetDefaultProfile(); diff --git a/MediaBrowser.Model/Dto/UserItemDataDto.cs b/MediaBrowser.Model/Dto/UserItemDataDto.cs index 6ee9f1916..ce0c8fa99 100644 --- a/MediaBrowser.Model/Dto/UserItemDataDto.cs +++ b/MediaBrowser.Model/Dto/UserItemDataDto.cs @@ -69,6 +69,12 @@ namespace MediaBrowser.Model.Dto /// The key. public string Key { get; set; } + /// + /// Gets or sets the item identifier. + /// + /// The item identifier. + public string ItemId { get; set; } + public event PropertyChangedEventHandler PropertyChanged; } } diff --git a/MediaBrowser.Model/Session/ClientCapabilities.cs b/MediaBrowser.Model/Session/ClientCapabilities.cs index 019eb3841..f00b14545 100644 --- a/MediaBrowser.Model/Session/ClientCapabilities.cs +++ b/MediaBrowser.Model/Session/ClientCapabilities.cs @@ -21,8 +21,8 @@ namespace MediaBrowser.Model.Session public DeviceProfile DeviceProfile { get; set; } public List SupportedLiveMediaTypes { get; set; } - public string Url { get; set; } - public string ImageUrl { get; set; } + public string AppStoreUrl { get; set; } + public string IconUrl { get; set; } public ClientCapabilities() { diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 62def8b8b..3cfecdeaf 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -141,7 +141,6 @@ namespace MediaBrowser.Providers.Manager updateType = updateType | result.UpdateType; refreshResult.AddStatus(result.Status, result.ErrorMessage); refreshResult.SetDateLastMetadataRefresh(DateTime.UtcNow); - refreshResult.AddMetadataProvidersRefreshed(result.Providers); MergeIdentities(itemOfType, id); } @@ -159,7 +158,6 @@ namespace MediaBrowser.Providers.Manager updateType = updateType | result.UpdateType; refreshResult.AddStatus(result.Status, result.ErrorMessage); refreshResult.SetDateLastImagesRefresh(DateTime.UtcNow); - refreshResult.AddImageProvidersRefreshed(result.Providers); } } diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index ccd427a47..008363ca4 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -68,7 +68,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints } keys.Add(e.Item); - + var baseItem = e.Item as BaseItem; // Go up one level for indicators @@ -117,7 +117,12 @@ namespace MediaBrowser.Server.Implementations.EntryPoints var dtoList = pair.Value .DistinctBy(i => i.Id) - .Select(i => _userDataManager.GetUserDataDto(i, user)) + .Select(i => + { + var dto = _userDataManager.GetUserDataDto(i, user); + dto.ItemId = i.Id.ToString("N"); + return dto; + }) .ToList(); var info = new UserDataChangeInfo diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index d5d0af74c..73dcc69d2 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -209,7 +209,7 @@ namespace MediaBrowser.Server.Implementations.Library var enableRichView = !user.Configuration.PlainFolderViews.Contains(parentId.ToString("N"), StringComparer.OrdinalIgnoreCase); - if (_config.Configuration.EnableUserSpecificUserViews) + if (_config.Configuration.EnableUserSpecificUserViews || !enableRichView) { viewType = enableRichView ? viewType : null; var view = await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false); @@ -222,7 +222,6 @@ namespace MediaBrowser.Server.Implementations.Library return view; } - viewType = enableRichView ? viewType : CollectionType.Folders; return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false); } else diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteProviderInfoRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteProviderInfoRepository.cs index f4820f432..743d8fed6 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteProviderInfoRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteProviderInfoRepository.cs @@ -208,15 +208,7 @@ namespace MediaBrowser.Server.Implementations.Persistence result.LastErrorMessage = reader.GetString(7); } - if (!reader.IsDBNull(8)) - { - result.MetadataProvidersRefreshed = reader.GetString(8).Split('|').Where(i => !string.IsNullOrEmpty(i)).Select(i => new Guid(i)).ToList(); - } - - if (!reader.IsDBNull(9)) - { - result.ImageProvidersRefreshed = reader.GetString(9).Split('|').Where(i => !string.IsNullOrEmpty(i)).Select(i => new Guid(i)).ToList(); - } + // Skip metadata and image providers if (!reader.IsDBNull(10)) { @@ -251,8 +243,8 @@ namespace MediaBrowser.Server.Implementations.Persistence _saveStatusCommand.GetParameter(5).Value = status.DateLastImagesRefresh; _saveStatusCommand.GetParameter(6).Value = status.LastStatus.ToString(); _saveStatusCommand.GetParameter(7).Value = status.LastErrorMessage; - _saveStatusCommand.GetParameter(8).Value = string.Join("|", status.MetadataProvidersRefreshed.ToArray()); - _saveStatusCommand.GetParameter(9).Value = string.Join("|", status.ImageProvidersRefreshed.ToArray()); + _saveStatusCommand.GetParameter(8).Value = string.Empty; + _saveStatusCommand.GetParameter(9).Value = string.Empty; _saveStatusCommand.GetParameter(10).Value = status.ItemDateModified; _saveStatusCommand.Transaction = transaction; diff --git a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs index c68487440..8c142b646 100644 --- a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs @@ -9,18 +9,18 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Photos { - public class PhotoAlbumImageProvider : BaseDynamicImageProvider - { - public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor) - { - } + //public class PhotoAlbumImageProvider : BaseDynamicImageProvider + //{ + // public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor) + // { + // } - protected override Task> GetItemsWithImages(IHasImages item) - { - var photoAlbum = (PhotoAlbum)item; - var items = GetFinalItems(photoAlbum.Children.ToList()); + // protected override Task> GetItemsWithImages(IHasImages item) + // { + // var photoAlbum = (PhotoAlbum)item; + // var items = GetFinalItems(photoAlbum.Children.ToList()); - return Task.FromResult(items); - } - } + // return Task.FromResult(items); + // } + //} }