From 1ad990ad720931309afadd9f7912d66595dcc04e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 19 Aug 2017 15:43:35 -0400 Subject: update live tv data transfer --- Emby.Server.Implementations/Library/LibraryManager.cs | 6 +++--- Emby.Server.Implementations/Library/SearchEngine.cs | 2 +- Emby.Server.Implementations/Library/UserDataManager.cs | 4 ++-- Emby.Server.Implementations/Library/UserViewManager.cs | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'Emby.Server.Implementations/Library') diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 40dccf9ba..bf3afd050 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1208,7 +1208,7 @@ namespace Emby.Server.Implementations.Library .Where(i => string.Equals(ShortcutFileExtension, Path.GetExtension(i), StringComparison.OrdinalIgnoreCase)) .Select(_fileSystem.ResolveShortcut) .OrderBy(i => i) - .ToList(), + .ToArray(), CollectionType = GetCollectionType(dir) }; @@ -1554,7 +1554,7 @@ namespace Emby.Server.Implementations.Library IncludeHidden = true, IncludeExternalContent = allowExternalContent - }, CancellationToken.None).Result.ToList(); + }, CancellationToken.None).Result; query.TopParentIds = userViews.SelectMany(i => GetTopParentIdsForQuery(i, user)).Select(i => i.ToString("N")).ToArray(); } @@ -3061,7 +3061,7 @@ namespace Emby.Server.Implementations.Library var topLibraryFolders = GetUserRootFolder().Children.ToList(); var info = GetVirtualFolderInfo(virtualFolderPath, topLibraryFolders, null); - if (info.Locations.Count > 0 && info.Locations.Count != options.PathInfos.Length) + if (info.Locations.Length > 0 && info.Locations.Length != options.PathInfos.Length) { var list = options.PathInfos.ToList(); diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs index 658558ec0..d4c4f2794 100644 --- a/Emby.Server.Implementations/Library/SearchEngine.cs +++ b/Emby.Server.Implementations/Library/SearchEngine.cs @@ -181,7 +181,7 @@ namespace Emby.Server.Implementations.Library DtoOptions = new DtoOptions { - Fields = new List + Fields = new ItemFields[] { ItemFields.AirTime, ItemFields.DateCreated, diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index e066ab61b..1f2bf97a3 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -187,11 +187,11 @@ namespace Emby.Server.Implementations.Library var userData = GetUserData(user.Id, item); var dto = GetUserItemDataDto(userData); - item.FillUserDataDtoValues(dto, userData, null, user, new List()); + item.FillUserDataDtoValues(dto, userData, null, user, new ItemFields[]{}); return dto; } - public UserItemDataDto GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user, List fields) + public UserItemDataDto GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user, ItemFields[] fields) { var userData = GetUserData(user.Id, item); var dto = GetUserItemDataDto(userData); diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index 0d4303b16..25c3e10e8 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -39,7 +39,7 @@ namespace Emby.Server.Implementations.Library _config = config; } - public async Task> GetUserViews(UserViewQuery query, CancellationToken cancellationToken) + public async Task GetUserViews(UserViewQuery query, CancellationToken cancellationToken) { var user = _userManager.GetUserById(query.UserId); @@ -154,7 +154,8 @@ namespace Emby.Server.Implementations.Library return index == -1 ? int.MaxValue : index; }) .ThenBy(sorted.IndexOf) - .ThenBy(i => i.SortName); + .ThenBy(i => i.SortName) + .ToArray(); } public Task GetUserSubView(string name, string parentId, string type, string sortName, CancellationToken cancellationToken) -- cgit v1.2.3 From f4765a87cc15efb06331aaeeff3c695be4e77f07 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Aug 2017 15:10:00 -0400 Subject: update m3u tuner --- .../Library/LibraryManager.cs | 12 +- .../LiveTv/TunerHosts/M3UTunerHost.cs | 127 ++++++++++++--------- .../LiveTv/TunerHosts/M3uParser.cs | 18 +-- .../Updates/InstallationManager.cs | 8 +- .../Entities/AggregateFolder.cs | 8 +- .../Entities/CollectionFolder.cs | 8 +- MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 38 ------ MediaBrowser.Controller/IO/FileData.cs | 10 +- MediaBrowser.Controller/Library/ILibraryManager.cs | 2 +- MediaBrowser.Controller/Library/ItemResolveArgs.cs | 29 +---- MediaBrowser.Controller/LiveTv/ChannelInfo.cs | 2 + MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 1 + 12 files changed, 106 insertions(+), 157 deletions(-) (limited to 'Emby.Server.Implementations/Library') diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index bf3afd050..1bfc93e79 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -353,7 +353,7 @@ namespace Emby.Server.Implementations.Library } else { - if (item is Photo) + if (!(item is Video)) { return; } @@ -599,18 +599,16 @@ namespace Emby.Server.Implementations.Library // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, _fileSystem, _logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, _fileSystem, _logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } // Check to see if we should resolve based on our contents @@ -656,7 +654,7 @@ namespace Emby.Server.Implementations.Library return false; } - public IEnumerable NormalizeRootPathList(IEnumerable paths) + public List NormalizeRootPathList(IEnumerable paths) { var originalList = paths.ToList(); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 2c12f4ca1..1bc334f06 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -25,12 +25,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts private readonly IHttpClient _httpClient; private readonly IServerApplicationHost _appHost; private readonly IEnvironmentInfo _environment; + private readonly INetworkManager _networkManager; - public M3UTunerHost(IServerConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IHttpClient httpClient, IServerApplicationHost appHost, IEnvironmentInfo environment) : base(config, logger, jsonSerializer, mediaEncoder, fileSystem) + public M3UTunerHost(IServerConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IHttpClient httpClient, IServerApplicationHost appHost, IEnvironmentInfo environment, INetworkManager networkManager) : base(config, logger, jsonSerializer, mediaEncoder, fileSystem) { _httpClient = httpClient; _appHost = appHost; _environment = environment; + _networkManager = networkManager; } public override string Type @@ -38,7 +40,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts get { return "m3u"; } } - public string Name + public virtual string Name { get { return "M3U Tuner"; } } @@ -99,72 +101,83 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false); - var m3uchannels = channels.Cast(); - var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); + var channel = channels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); if (channel != null) { - var path = channel.Path; - MediaProtocol protocol = MediaProtocol.File; - if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Http; - } - else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtmp; - } - else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtsp; - } - else if (path.StartsWith("udp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Udp; - } - else if (path.StartsWith("rtp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtmp; - } + return new List { CreateMediaSourceInfo(info, channel) }; + } + return new List(); + } + + protected virtual MediaSourceInfo CreateMediaSourceInfo(TunerHostInfo info, ChannelInfo channel) + { + var path = channel.Path; + MediaProtocol protocol = MediaProtocol.File; + if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Http; + } + else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtmp; + } + else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtsp; + } + else if (path.StartsWith("udp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Udp; + } + else if (path.StartsWith("rtp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtmp; + } + + Uri uri; + var isRemote = true; + if (Uri.TryCreate(path, UriKind.Absolute, out uri)) + { + isRemote = !_networkManager.IsInLocalNetwork(uri.Host); + } - var mediaSource = new MediaSourceInfo + var mediaSource = new MediaSourceInfo + { + Path = path, + Protocol = protocol, + MediaStreams = new List { - Path = channel.Path, - Protocol = protocol, - MediaStreams = new List + new MediaStream { - new MediaStream - { - Type = MediaStreamType.Video, - // Set the index to -1 because we don't know the exact index of the video stream within the container - Index = -1, - IsInterlaced = true - }, - new MediaStream - { - Type = MediaStreamType.Audio, - // Set the index to -1 because we don't know the exact index of the audio stream within the container - Index = -1 - - } + Type = MediaStreamType.Video, + // Set the index to -1 because we don't know the exact index of the video stream within the container + Index = -1, + IsInterlaced = true }, - RequiresOpening = true, - RequiresClosing = true, - RequiresLooping = info.EnableStreamLooping, + new MediaStream + { + Type = MediaStreamType.Audio, + // Set the index to -1 because we don't know the exact index of the audio stream within the container + Index = -1 - ReadAtNativeFramerate = false, + } + }, + RequiresOpening = true, + RequiresClosing = true, + RequiresLooping = info.EnableStreamLooping, - Id = channel.Path.GetMD5().ToString("N"), - IsInfiniteStream = true, - IsRemote = true, + ReadAtNativeFramerate = false, - IgnoreDts = true - }; + Id = channel.Path.GetMD5().ToString("N"), + IsInfiniteStream = true, + IsRemote = isRemote, - mediaSource.InferTotalBitrate(); + IgnoreDts = true + }; - return new List { mediaSource }; - } - return new List(); + mediaSource.InferTotalBitrate(); + + return mediaSource; } protected override Task IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 113e691b6..ca744b615 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts _appHost = appHost; } - public async Task> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken) + public async Task> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken) { // Read the file and display it line by line. using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false))) @@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } - public List ParseString(string text, string channelIdPrefix, string tunerHostId) + public List ParseString(string text, string channelIdPrefix, string tunerHostId) { // Read the file and display it line by line. using (var reader = new StringReader(text)) @@ -66,9 +66,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } const string ExtInfPrefix = "#EXTINF:"; - private List GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId) + private List GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId) { - var channels = new List(); + var channels = new List(); string line; string extInf = ""; @@ -111,9 +111,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return channels; } - private M3UChannel GetChannelnfo(string extInf, string tunerHostId, string mediaUrl) + private ChannelInfo GetChannelnfo(string extInf, string tunerHostId, string mediaUrl) { - var channel = new M3UChannel(); + var channel = new ChannelInfo(); channel.TunerHostId = tunerHostId; extInf = extInf.Trim(); @@ -335,10 +335,4 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return dict; } } - - - public class M3UChannel : ChannelInfo - { - public string Path { get; set; } - } } \ No newline at end of file diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 6f9c85671..ab1255b57 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -308,9 +308,11 @@ namespace Emby.Server.Implementations.Updates .OrderByDescending(GetPackageVersion).ToArray(); } + IEnumerable packagesList = packages; + if (!string.IsNullOrWhiteSpace(packageType)) { - packages = packages.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)).ToArray(); + packagesList = packagesList.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)); } // If an app version was supplied, filter the versions for each package to only include supported versions @@ -323,7 +325,9 @@ namespace Emby.Server.Implementations.Updates } // Remove packages with no versions - return packages.Where(p => p.versions.Any()).ToArray(); + packagesList = packagesList.Where(p => p.versions.Any()); + + return packagesList.ToArray(); } /// diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index f88522f78..db84d6e2f 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -148,18 +148,16 @@ namespace MediaBrowser.Controller.Entities // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = LibraryManager.NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = LibraryManager.NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index d02e469d4..3e2c501b4 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -292,18 +292,16 @@ namespace MediaBrowser.Controller.Entities // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = LibraryManager.NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = LibraryManager.NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 376f65d60..2768d8465 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.Serialization; -using MediaBrowser.Controller.Entities.Audio; namespace MediaBrowser.Controller.Entities.Movies { @@ -82,20 +81,11 @@ namespace MediaBrowser.Controller.Entities.Movies protected override IEnumerable GetNonCachedChildren(IDirectoryService directoryService) { - if (IsLegacyBoxSet) - { - return base.GetNonCachedChildren(directoryService); - } return new List(); } protected override List LoadChildren() { - if (IsLegacyBoxSet) - { - return base.LoadChildren(); - } - // Save a trip to the database return new List(); } @@ -109,34 +99,6 @@ namespace MediaBrowser.Controller.Entities.Movies } } - [IgnoreDataMember] - protected override bool SupportsShortcutChildren - { - get - { - if (IsLegacyBoxSet) - { - return false; - } - - return false; - } - } - - [IgnoreDataMember] - private bool IsLegacyBoxSet - { - get - { - if (string.IsNullOrWhiteSpace(Path)) - { - return false; - } - - return !FileSystem.ContainsSubPath(ConfigurationManager.ApplicationPaths.DataPath, Path); - } - } - public override bool IsAuthorizedToDelete(User user) { return true; diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 64a7610fe..27af60700 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -3,7 +3,7 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; - +using System.Linq; using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.IO @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.IO /// if set to true [resolve shortcuts]. /// Dictionary{System.StringFileSystemInfo}. /// path - public static Dictionary GetFilteredFileSystemEntries(IDirectoryService directoryService, + public static FileSystemMetadata[] GetFilteredFileSystemEntries(IDirectoryService directoryService, string path, IFileSystem fileSystem, ILogger logger, @@ -57,7 +57,7 @@ namespace MediaBrowser.Controller.IO if (!resolveShortcuts && flattenFolderDepth == 0) { - return GetFileSystemDictionary(entries); + return entries; } var dict = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -98,7 +98,7 @@ namespace MediaBrowser.Controller.IO { foreach (var child in GetFilteredFileSystemEntries(directoryService, fullName, fileSystem, logger, args, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts)) { - dict[child.Key] = child.Value; + dict[child.FullName] = child; } } else @@ -107,7 +107,7 @@ namespace MediaBrowser.Controller.IO } } - return dict; + return dict.Values.ToArray(); } } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 025254d4b..cd1781220 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -277,7 +277,7 @@ namespace MediaBrowser.Controller.Library /// /// The paths. /// IEnumerable{System.String}. - IEnumerable NormalizeRootPathList(IEnumerable paths); + List NormalizeRootPathList(IEnumerable paths); /// /// Registers the item. diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 76b6d8768..963e4b71b 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -40,20 +40,7 @@ namespace MediaBrowser.Controller.Library /// Gets the file system children. /// /// The file system children. - public IEnumerable FileSystemChildren - { - get - { - var dict = FileSystemDictionary; - - if (dict == null) - { - return new List(); - } - - return dict.Values; - } - } + public FileSystemMetadata[] FileSystemChildren { get; set; } public LibraryOptions LibraryOptions { get; set; } @@ -62,12 +49,6 @@ namespace MediaBrowser.Controller.Library return LibraryOptions ?? (LibraryOptions = (Parent == null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent))); } - /// - /// Gets or sets the file system dictionary. - /// - /// The file system dictionary. - public Dictionary FileSystemDictionary { get; set; } - /// /// Gets or sets the parent. /// @@ -224,13 +205,11 @@ namespace MediaBrowser.Controller.Library throw new ArgumentNullException(); } - if (FileSystemDictionary != null) + foreach (var file in FileSystemChildren) { - FileSystemMetadata entry; - - if (FileSystemDictionary.TryGetValue(path, out entry)) + if (string.Equals(file.FullName, path, StringComparison.Ordinal)) { - return entry; + return file; } } diff --git a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs index 6682942ad..892a7d5b7 100644 --- a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs +++ b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs @@ -25,6 +25,8 @@ namespace MediaBrowser.Controller.LiveTv /// The id of the channel. public string Id { get; set; } + public string Path { get; set; } + public string TunerChannelId { get; set; } public string CallSign { get; set; } diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 64b628a13..15f60d831 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -48,6 +48,7 @@ namespace MediaBrowser.Model.LiveTv public bool AllowHWTranscoding { get; set; } public bool EnableStreamLooping { get; set; } public bool EnableNewHdhrChannelIds { get; set; } + public string Source { get; set; } public TunerHostInfo() { -- cgit v1.2.3 From 8732a603458ed32cf9e5834edc012b0409538294 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:48:03 -0400 Subject: set season name in SeasonResolver --- .../Library/Resolvers/TV/SeasonResolver.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Emby.Server.Implementations/Library') diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs index 84ceac65e..830bd9d85 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs @@ -1,6 +1,8 @@ -using MediaBrowser.Controller.Configuration; +using System.Globalization; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Globalization; using MediaBrowser.Naming.Common; using MediaBrowser.Naming.TV; @@ -17,15 +19,18 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV private readonly IServerConfigurationManager _config; private readonly ILibraryManager _libraryManager; + private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); + private readonly ILocalizationManager _localization; /// /// Initializes a new instance of the class. /// /// The config. - public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager) + public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager, ILocalizationManager localization) { _config = config; _libraryManager = libraryManager; + _localization = localization; } /// @@ -47,9 +52,13 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV SeriesName = series.Name }; - if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0) + if (season.IndexNumber.HasValue) { - season.Name = _config.Configuration.SeasonZeroDisplayName; + var seasonNumber = season.IndexNumber.Value; + + season.Name = seasonNumber == 0 ? + _config.Configuration.SeasonZeroDisplayName : + string.Format(_localization.GetLocalizedString("NameSeasonNumber"), seasonNumber.ToString(UsCulture)); } return season; -- cgit v1.2.3 From e441e2f53db0b587c9864fe91d7008a2344d147b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 24 Aug 2017 15:52:19 -0400 Subject: update active recordings --- Emby.Dlna/ContentDirectory/ContentDirectory.cs | 18 +++- Emby.Dlna/Didl/Filter.cs | 7 +- Emby.Dlna/Didl/StringWriterWithEncoding.cs | 1 - Emby.Dlna/PlayTo/PlayToController.cs | 5 +- Emby.Dlna/Profiles/PanasonicVieraProfile.cs | 101 --------------------- Emby.Dlna/Ssdp/Extensions.cs | 9 +- Emby.Drawing.ImageMagick/ImageHelpers.cs | 6 +- Emby.Drawing.ImageMagick/ImageMagickEncoder.cs | 7 +- Emby.Drawing.ImageMagick/StripCollageBuilder.cs | 12 +-- Emby.Drawing/ImageProcessor.cs | 24 +++-- Emby.Server.Implementations/ApplicationHost.cs | 10 +- .../Channels/ChannelManager.cs | 2 +- .../Data/SqliteItemRepository.cs | 6 +- Emby.Server.Implementations/Dto/DtoService.cs | 2 +- .../Library/Resolvers/SpecialFolderResolver.cs | 2 +- .../LiveTv/EmbyTV/EmbyTV.cs | 61 +++---------- .../Notifications/Notifications.cs | 4 +- .../Services/ServiceHandler.cs | 8 +- .../Sorting/ArtistComparer.cs | 2 +- .../Updates/InstallationManager.cs | 91 +++++++++++++------ MediaBrowser.Api/ChannelService.cs | 2 +- MediaBrowser.Api/ConfigurationService.cs | 1 - MediaBrowser.Api/Devices/DeviceService.cs | 3 +- MediaBrowser.Api/Dlna/DlnaServerService.cs | 1 - MediaBrowser.Api/Dlna/DlnaService.cs | 4 +- MediaBrowser.Api/Images/ImageService.cs | 15 +-- MediaBrowser.Api/ItemUpdateService.cs | 2 +- MediaBrowser.Api/LocalizationService.cs | 1 - MediaBrowser.Api/Movies/CollectionService.cs | 1 - MediaBrowser.Api/Movies/MoviesService.cs | 2 +- MediaBrowser.Api/PlaylistService.cs | 4 +- MediaBrowser.Api/Reports/Data/ReportBuilder.cs | 2 +- MediaBrowser.Api/SearchService.cs | 8 +- MediaBrowser.Api/SuggestionsService.cs | 1 - MediaBrowser.Api/TvShowsService.cs | 1 - MediaBrowser.Api/UserLibrary/ArtistsService.cs | 2 +- .../UserLibrary/BaseItemsByNameService.cs | 12 +-- MediaBrowser.Api/UserLibrary/GameGenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/GenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/MusicGenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/PersonsService.cs | 12 +-- MediaBrowser.Api/UserLibrary/StudiosService.cs | 6 +- MediaBrowser.Api/UserLibrary/YearsService.cs | 6 +- MediaBrowser.Api/VideosService.cs | 1 - .../Updates/IInstallationManager.cs | 4 +- MediaBrowser.Controller/Drawing/IImageProcessor.cs | 4 +- .../Entities/AggregateFolder.cs | 31 ++++--- MediaBrowser.Controller/Entities/Audio/Audio.cs | 22 +++-- .../Entities/Audio/IHasAlbumArtist.cs | 16 +--- .../Entities/Audio/MusicAlbum.cs | 62 +++++++------ .../Entities/Audio/MusicArtist.cs | 20 ++-- .../Entities/Audio/MusicGenre.cs | 1 - MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- MediaBrowser.Controller/Entities/Book.cs | 2 +- .../Entities/CollectionFolder.cs | 26 +++--- MediaBrowser.Controller/Entities/Game.cs | 1 - MediaBrowser.Controller/Entities/GameGenre.cs | 1 - MediaBrowser.Controller/Entities/Genre.cs | 1 - .../Entities/ICollectionFolder.cs | 2 +- .../Entities/InternalPeopleQuery.cs | 4 +- MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 5 +- MediaBrowser.Controller/Entities/MusicVideo.cs | 6 +- MediaBrowser.Controller/Entities/PeopleHelper.cs | 10 +- MediaBrowser.Controller/Entities/Person.cs | 1 - MediaBrowser.Controller/Entities/Photo.cs | 12 ++- MediaBrowser.Controller/Entities/Studio.cs | 1 - MediaBrowser.Controller/Entities/TV/Season.cs | 2 +- MediaBrowser.Controller/Entities/TV/Series.cs | 10 +- MediaBrowser.Controller/Entities/User.cs | 19 +++- MediaBrowser.Controller/Entities/UserRootFolder.cs | 2 +- MediaBrowser.Controller/Entities/UserView.cs | 4 +- MediaBrowser.Controller/Entities/Year.cs | 1 - MediaBrowser.Controller/IO/FileData.cs | 11 ++- MediaBrowser.Controller/Library/ItemResolveArgs.cs | 14 ++- MediaBrowser.Controller/Library/NameExtensions.cs | 44 --------- .../LiveTv/LiveTvAudioRecording.cs | 1 - MediaBrowser.Controller/LiveTv/LiveTvProgram.cs | 1 - .../LiveTv/LiveTvVideoRecording.cs | 1 - .../Providers/DirectoryService.cs | 16 +++- .../Providers/IDirectoryService.cs | 2 +- .../Providers/MetadataResult.cs | 11 ++- MediaBrowser.Controller/Providers/SongInfo.cs | 5 +- MediaBrowser.Controller/Session/SessionInfo.cs | 15 ++- .../Images/EpisodeLocalImageProvider.cs | 71 +++++++-------- .../Images/LocalImageProvider.cs | 1 - MediaBrowser.Model/Dto/BaseItemDto.cs | 2 +- MediaBrowser.Model/Dto/MediaSourceInfo.cs | 17 ++-- MediaBrowser.Model/Extensions/ListHelper.cs | 11 ++- .../Services/QueryParamCollection.cs | 67 ++++++++++---- MediaBrowser.Model/Updates/PackageVersionInfo.cs | 2 + .../Books/AudioBookMetadataService.cs | 4 +- .../Books/AudioPodcastMetadataService.cs | 4 +- .../BoxSets/BoxSetMetadataService.cs | 6 +- MediaBrowser.Providers/Chapters/ChapterManager.cs | 1 - .../Manager/GenericPriorityQueue.cs | 1 - .../Manager/GenericPriorityQueueNode.cs | 1 - .../Manager/IFixedSizePriorityQueue.cs | 1 - MediaBrowser.Providers/Manager/IPriorityQueue.cs | 1 - .../Manager/SimplePriorityQueue.cs | 1 - .../MediaInfo/AudioImageProvider.cs | 2 +- .../MediaInfo/FFProbeAudioInfo.cs | 2 +- .../Music/AlbumMetadataService.cs | 4 +- .../Music/ArtistMetadataService.cs | 2 +- .../Music/AudioMetadataService.cs | 4 +- .../Music/MusicVideoMetadataService.cs | 4 +- .../Playlists/PlaylistMetadataService.cs | 7 +- MediaBrowser.Server.Mono/Program.cs | 5 +- MediaBrowser.ServerApplication/Native/LoopUtil.cs | 1 - MediaBrowser.XbmcMetadata/EntryPoint.cs | 1 - .../Parsers/MovieNfoParser.cs | 7 +- MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs | 5 +- MediaBrowser.XbmcMetadata/Savers/ArtistNfoSaver.cs | 7 +- MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs | 4 +- Mono.Nat/NatUtility.cs | 1 - Mono.Nat/Pmp/Searchers/PmpSearcher.cs | 1 - Mono.Nat/Upnp/Upnp.cs | 1 - Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- RSSDP/CustomHttpHeaders.cs | 1 - RSSDP/DeviceAvailableEventArgs.cs | 1 - RSSDP/DeviceEventArgs.cs | 1 - RSSDP/DeviceUnavailableEventArgs.cs | 1 - RSSDP/DiscoveredSsdpDevice.cs | 1 - RSSDP/DisposableManagedObjectBase.cs | 1 - RSSDP/IUPnPDeviceValidator.cs | 4 +- RSSDP/RequestReceivedEventArgs.cs | 1 - RSSDP/ResponseReceivedEventArgs.cs | 1 - RSSDP/SsdpCommunicationsServer.cs | 2 +- RSSDP/SsdpConstants.cs | 1 - RSSDP/SsdpDevice.cs | 7 +- RSSDP/SsdpDeviceExtensions.cs | 1 - RSSDP/SsdpDeviceIcon.cs | 1 - RSSDP/SsdpDeviceLocator.cs | 1 - RSSDP/SsdpDeviceLocatorBase.cs | 37 +++++--- RSSDP/SsdpDeviceProperties.cs | 1 - RSSDP/SsdpDeviceProperty.cs | 1 - RSSDP/SsdpDevicePublisher.cs | 1 - RSSDP/SsdpEmbeddedDevice.cs | 1 - RSSDP/SsdpRootDevice.cs | 1 - RSSDP/UPnP10DeviceValidator.cs | 10 +- SocketHttpListener/Net/BoundaryType.cs | 1 - SocketHttpListener/Net/CookieHelper.cs | 1 - SocketHttpListener/Net/EndPointManager.cs | 5 +- SocketHttpListener/Net/EntitySendFormat.cs | 1 - .../Net/HttpListenerResponse.Managed.cs | 1 - SocketHttpListener/Net/HttpListenerResponse.cs | 1 - .../Net/HttpRequestStream.Managed.cs | 1 - SocketHttpListener/Net/HttpRequestStream.cs | 1 - .../Net/HttpResponseStream.Managed.cs | 1 - SocketHttpListener/Net/HttpResponseStream.cs | 1 - SocketHttpListener/Net/HttpStatusDescription.cs | 1 - SocketHttpListener/Net/UriScheme.cs | 1 - SocketHttpListener/Net/WebHeaderCollection.cs | 12 +-- SocketHttpListener/Net/WebHeaderEncoding.cs | 1 - SocketHttpListener/Primitives/ICertificate.cs | 1 - SocketHttpListener/Primitives/IStreamFactory.cs | 1 - SocketHttpListener/Primitives/ITextEncoding.cs | 1 - 157 files changed, 571 insertions(+), 657 deletions(-) (limited to 'Emby.Server.Implementations/Library') diff --git a/Emby.Dlna/ContentDirectory/ContentDirectory.cs b/Emby.Dlna/ContentDirectory/ContentDirectory.cs index 92d388e3b..d547ad8d4 100644 --- a/Emby.Dlna/ContentDirectory/ContentDirectory.cs +++ b/Emby.Dlna/ContentDirectory/ContentDirectory.cs @@ -10,7 +10,6 @@ using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.TV; using MediaBrowser.Model.Globalization; @@ -129,9 +128,20 @@ namespace Emby.Dlna.ContentDirectory } } - // No configuration so it's going to be pretty arbitrary - return _userManager.Users.FirstOrDefault(i => i.Policy.IsAdministrator) ?? - _userManager.Users.First(); + foreach (var user in _userManager.Users) + { + if (user.Policy.IsAdministrator) + { + return user; + } + } + + foreach (var user in _userManager.Users) + { + return user; + } + + return null; } public void Dispose() diff --git a/Emby.Dlna/Didl/Filter.cs b/Emby.Dlna/Didl/Filter.cs index 5e9aeb530..2c9a1ea18 100644 --- a/Emby.Dlna/Didl/Filter.cs +++ b/Emby.Dlna/Didl/Filter.cs @@ -1,13 +1,12 @@ using MediaBrowser.Model.Extensions; using System; using System.Collections.Generic; -using System.Linq; namespace Emby.Dlna.Didl { public class Filter { - private readonly List _fields; + private readonly string[] _fields; private readonly bool _all; public Filter() @@ -20,9 +19,7 @@ namespace Emby.Dlna.Didl { _all = StringHelper.EqualsIgnoreCase(filter, "*"); - var list = (filter ?? string.Empty).Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList(); - - _fields = list; + _fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } public bool Contains(string field) diff --git a/Emby.Dlna/Didl/StringWriterWithEncoding.cs b/Emby.Dlna/Didl/StringWriterWithEncoding.cs index 052d6610b..b5c565801 100644 --- a/Emby.Dlna/Didl/StringWriterWithEncoding.cs +++ b/Emby.Dlna/Didl/StringWriterWithEncoding.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index d563b5add..4b77f998d 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -13,7 +13,6 @@ using MediaBrowser.Model.System; using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Configuration; @@ -49,7 +48,7 @@ namespace Emby.Dlna.PlayTo { get { - var lastDateKnownActivity = new[] { _creationTime, _device.DateLastActivity }.Max(); + var lastDateKnownActivity = _creationTime > _device.DateLastActivity ? _creationTime : _device.DateLastActivity; if (DateTime.UtcNow >= lastDateKnownActivity.AddSeconds(120)) { @@ -565,7 +564,7 @@ namespace Emby.Dlna.PlayTo streamInfo.TargetVideoCodecTag, streamInfo.IsTargetAVC); - return list.FirstOrDefault(); + return list.Count == 0 ? null : list[0]; } return null; diff --git a/Emby.Dlna/Profiles/PanasonicVieraProfile.cs b/Emby.Dlna/Profiles/PanasonicVieraProfile.cs index 63c7e3a8e..095788485 100644 --- a/Emby.Dlna/Profiles/PanasonicVieraProfile.cs +++ b/Emby.Dlna/Profiles/PanasonicVieraProfile.cs @@ -30,107 +30,6 @@ namespace Emby.Dlna.Profiles TimelineOffsetSeconds = 10; - TranscodingProfiles = new[] - { - new TranscodingProfile - { - Container = "mp3", - AudioCodec = "mp3", - Type = DlnaProfileType.Audio - }, - new TranscodingProfile - { - Container = "ts", - AudioCodec = "ac3", - VideoCodec = "h264", - Type = DlnaProfileType.Video - }, - new TranscodingProfile - { - Container = "jpeg", - Type = DlnaProfileType.Photo - } - }; - - DirectPlayProfiles = new[] - { - new DirectPlayProfile - { - Container = "mpeg,mpg", - VideoCodec = "mpeg2video,mpeg4", - AudioCodec = "ac3,mp3,pcm_dvd", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mkv", - VideoCodec = "h264,mpeg2video", - AudioCodec = "aac,ac3,dca,mp3,mp2,pcm,dts", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "ts", - VideoCodec = "h264,mpeg2video", - AudioCodec = "aac,mp3,mp2", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mp4,m4v", - VideoCodec = "h264", - AudioCodec = "aac,ac3,mp3,pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mov", - VideoCodec = "h264", - AudioCodec = "aac,pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "avi", - VideoCodec = "mpeg4", - AudioCodec = "pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "flv", - VideoCodec = "h264", - AudioCodec = "aac", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mp3", - AudioCodec = "mp3", - Type = DlnaProfileType.Audio - }, - - new DirectPlayProfile - { - Container = "mp4", - AudioCodec = "aac", - Type = DlnaProfileType.Audio - }, - - new DirectPlayProfile - { - Container = "jpeg", - Type = DlnaProfileType.Photo - } - }; - ContainerProfiles = new[] { new ContainerProfile diff --git a/Emby.Dlna/Ssdp/Extensions.cs b/Emby.Dlna/Ssdp/Extensions.cs index 611bf7e02..41a361515 100644 --- a/Emby.Dlna/Ssdp/Extensions.cs +++ b/Emby.Dlna/Ssdp/Extensions.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Net; using System.Threading.Tasks; using System.Xml.Linq; @@ -24,10 +23,12 @@ namespace Emby.Dlna.Ssdp public static string GetDescendantValue(this XElement container, XName name) { - var node = container.Descendants(name) - .FirstOrDefault(); + foreach (var node in container.Descendants(name)) + { + return node.Value; + } - return node == null ? null : node.Value; + return null; } } } diff --git a/Emby.Drawing.ImageMagick/ImageHelpers.cs b/Emby.Drawing.ImageMagick/ImageHelpers.cs index c623c21aa..866693399 100644 --- a/Emby.Drawing.ImageMagick/ImageHelpers.cs +++ b/Emby.Drawing.ImageMagick/ImageHelpers.cs @@ -6,13 +6,13 @@ namespace Emby.Drawing.ImageMagick { internal static class ImageHelpers { - internal static List ProjectPaths(List paths, int count) + internal static List ProjectPaths(string[] paths, int count) { if (count <= 0) { throw new ArgumentOutOfRangeException("count"); } - if (paths.Count == 0) + if (paths.Length == 0) { throw new ArgumentOutOfRangeException("paths"); } @@ -24,7 +24,7 @@ namespace Emby.Drawing.ImageMagick return list.Take(count).ToList(); } - private static void AddToList(List list, List paths, int count) + private static void AddToList(List list, string[] paths, int count) { while (list.Count < count) { diff --git a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs index ea8687de0..9abf85e70 100644 --- a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs +++ b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs @@ -7,7 +7,6 @@ using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Logging; using System; using System.IO; -using System.Linq; using MediaBrowser.Model.IO; using MediaBrowser.Model.System; @@ -306,15 +305,15 @@ namespace Emby.Drawing.ImageMagick if (ratio >= 1.4) { - new StripCollageBuilder(_appPaths, _fileSystem).BuildThumbCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildThumbCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } else if (ratio >= .9) { - new StripCollageBuilder(_appPaths, _fileSystem).BuildSquareCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildSquareCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } else { - new StripCollageBuilder(_appPaths, _fileSystem).BuildPosterCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildPosterCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } } diff --git a/Emby.Drawing.ImageMagick/StripCollageBuilder.cs b/Emby.Drawing.ImageMagick/StripCollageBuilder.cs index 63cf8fe5f..26c6c868d 100644 --- a/Emby.Drawing.ImageMagick/StripCollageBuilder.cs +++ b/Emby.Drawing.ImageMagick/StripCollageBuilder.cs @@ -19,7 +19,7 @@ namespace Emby.Drawing.ImageMagick _fileSystem = fileSystem; } - public void BuildPosterCollage(List paths, string outputPath, int width, int height) + public void BuildPosterCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildPosterCollageWand(paths, width, height)) { @@ -27,7 +27,7 @@ namespace Emby.Drawing.ImageMagick } } - public void BuildSquareCollage(List paths, string outputPath, int width, int height) + public void BuildSquareCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildSquareCollageWand(paths, width, height)) { @@ -35,7 +35,7 @@ namespace Emby.Drawing.ImageMagick } } - public void BuildThumbCollage(List paths, string outputPath, int width, int height) + public void BuildThumbCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildThumbCollageWand(paths, width, height)) { @@ -43,7 +43,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildPosterCollageWand(List paths, int width, int height) + private MagickWand BuildPosterCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 3); using (var wandImages = new MagickWand(inputPaths.ToArray())) @@ -108,7 +108,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildThumbCollageWand(List paths, int width, int height) + private MagickWand BuildThumbCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 4); using (var wandImages = new MagickWand(inputPaths.ToArray())) @@ -173,7 +173,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildSquareCollageWand(List paths, int width, int height) + private MagickWand BuildSquareCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 4); var outputWand = new MagickWand(width, height, new PixelWand("none", 1)); diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index bd23eba7a..63fa5f1f5 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -44,7 +44,7 @@ namespace Emby.Drawing /// Image processors are specialized metadata providers that run after the normal ones /// /// The image enhancers. - public IEnumerable ImageEnhancers { get; private set; } + public IImageEnhancer[] ImageEnhancers { get; private set; } /// /// The _logger @@ -71,7 +71,7 @@ namespace Emby.Drawing _libraryManager = libraryManager; _appPaths = appPaths; - ImageEnhancers = new List(); + ImageEnhancers = new IImageEnhancer[] {}; _saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite); ImageHelper.ImageProcessor = this; @@ -618,7 +618,7 @@ namespace Emby.Drawing var supportedEnhancers = GetSupportedEnhancers(item, image.Type); - return GetImageCacheTag(item, image, supportedEnhancers.ToList()); + return GetImageCacheTag(item, image, supportedEnhancers); } /// @@ -672,7 +672,7 @@ namespace Emby.Drawing /// Task{System.String}. public async Task GetEnhancedImage(IHasMetadata item, ImageType imageType, int imageIndex) { - var enhancers = GetSupportedEnhancers(item, imageType).ToList(); + var enhancers = GetSupportedEnhancers(item, imageType); var imageInfo = item.GetImageInfo(imageType, imageIndex); @@ -866,21 +866,25 @@ namespace Emby.Drawing _logger.Info("Completed creation of image collage and saved to {0}", options.OutputPath); } - public IEnumerable GetSupportedEnhancers(IHasMetadata item, ImageType imageType) + public List GetSupportedEnhancers(IHasMetadata item, ImageType imageType) { - return ImageEnhancers.Where(i => + var list = new List(); + + foreach (var i in ImageEnhancers) { try { - return i.Supports(item, imageType); + if (i.Supports(item, imageType)) + { + list.Add(i); + } } catch (Exception ex) { _logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); - - return false; } - }); + } + return list; } private bool _disposed; diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index ea6c2aaf5..6441fe4f2 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -861,7 +861,7 @@ namespace Emby.Server.Implementations SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager, FileSystemManager, CryptographyProvider); RegisterSingleInstance(SecurityManager); - InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager, CryptographyProvider); + InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager, CryptographyProvider, PackageRuntime); RegisterSingleInstance(InstallationManager); ZipClient = new ZipClient(FileSystemManager); @@ -1048,6 +1048,14 @@ namespace Emby.Server.Implementations await ((UserManager)UserManager).Initialize().ConfigureAwait(false); } + protected virtual string PackageRuntime + { + get + { + return "netframework"; + } + } + public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, bool isStartup) { logger.LogMultiline("Emby", LogSeverity.Info, GetBaseExceptionMessage(appPaths)); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 28a150370..d8d69a62e 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -1330,7 +1330,7 @@ namespace Emby.Server.Implementations.Channels var hasArtists = item as IHasArtist; if (hasArtists != null) { - hasArtists.Artists = info.Artists; + hasArtists.Artists = info.Artists.ToArray(); } var hasAlbumArtists = item as IHasAlbumArtist; diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 064a66cd0..423ad2782 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -1028,9 +1028,9 @@ namespace Emby.Server.Implementations.Data var hasArtists = item as IHasArtist; if (hasArtists != null) { - if (hasArtists.Artists.Count > 0) + if (hasArtists.Artists.Length > 0) { - artists = string.Join("|", hasArtists.Artists.ToArray()); + artists = string.Join("|", hasArtists.Artists); } } saveItemStatement.TryBind("@Artists", artists); @@ -1908,7 +1908,7 @@ namespace Emby.Server.Implementations.Data var hasArtists = item as IHasArtist; if (hasArtists != null && !reader.IsDBNull(index)) { - hasArtists.Artists = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); + hasArtists.Artists = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } index++; diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 17e91bfa8..028257270 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1617,7 +1617,7 @@ namespace Emby.Server.Implementations.Dto return null; } - var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList(); + var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary); ImageSize size; diff --git a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs index 6c7c1f052..6a1f8ec6f 100644 --- a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Library.Resolvers return new CollectionFolder { CollectionType = GetCollectionType(args), - PhysicalLocationsList = args.PhysicalLocations.ToList() + PhysicalLocationsList = args.PhysicalLocations }; } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index f3d40ae19..2e12f46bf 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -607,20 +607,22 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var timer = _timerProvider.GetTimer(timerId); if (timer != null) { + timer.Status = RecordingStatus.Cancelled; + if (string.IsNullOrWhiteSpace(timer.SeriesTimerId) || isSeriesCancelled) { _timerProvider.Delete(timer); } else { - timer.Status = RecordingStatus.Cancelled; _timerProvider.AddOrUpdate(timer, false); } } ActiveRecordingInfo activeRecordingInfo; if (_activeRecordings.TryGetValue(timerId, out activeRecordingInfo)) - { + { + activeRecordingInfo.Timer = timer; activeRecordingInfo.CancellationTokenSource.Cancel(); } } @@ -865,7 +867,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public async Task> GetRecordingsAsync(CancellationToken cancellationToken) { return new List(); - //return _activeRecordings.Values.ToList().Select(GetRecordingInfo).ToList(); } public string GetActiveRecordingPath(string id) @@ -881,7 +882,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public IEnumerable GetAllActiveRecordings() { - return _activeRecordings.Values; + return _activeRecordings.Values.Where(i => i.Timer.Status == RecordingStatus.InProgress && !i.CancellationTokenSource.IsCancellationRequested); } public ActiveRecordingInfo GetActiveRecordingInfo(string path) @@ -893,59 +894,19 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV foreach (var recording in _activeRecordings.Values) { - if (string.Equals(recording.Path, path, StringComparison.Ordinal)) + if (string.Equals(recording.Path, path, StringComparison.Ordinal) && !recording.CancellationTokenSource.IsCancellationRequested) { + var timer = recording.Timer; + if (timer.Status != RecordingStatus.InProgress) + { + return null; + } return recording; } } return null; } - private RecordingInfo GetRecordingInfo(ActiveRecordingInfo info) - { - var timer = info.Timer; - var program = info.Program; - - var result = new RecordingInfo - { - ChannelId = timer.ChannelId, - CommunityRating = timer.CommunityRating, - DateLastUpdated = DateTime.UtcNow, - EndDate = timer.EndDate, - EpisodeTitle = timer.EpisodeTitle, - Genres = timer.Genres, - Id = "recording" + timer.Id, - IsKids = timer.IsKids, - IsMovie = timer.IsMovie, - IsNews = timer.IsNews, - IsRepeat = timer.IsRepeat, - IsSeries = timer.IsProgramSeries, - IsSports = timer.IsSports, - Name = timer.Name, - OfficialRating = timer.OfficialRating, - OriginalAirDate = timer.OriginalAirDate, - Overview = timer.Overview, - ProgramId = timer.ProgramId, - SeriesTimerId = timer.SeriesTimerId, - StartDate = timer.StartDate, - Status = RecordingStatus.InProgress, - TimerId = timer.Id - }; - - if (program != null) - { - result.Audio = program.Audio; - result.ImagePath = program.ImagePath; - result.ImageUrl = program.ImageUrl; - result.IsHD = program.IsHD; - result.IsLive = program.IsLive; - result.IsPremiere = program.IsPremiere; - result.ShowId = program.ShowId; - } - - return result; - } - public Task> GetTimersAsync(CancellationToken cancellationToken) { var excludeStatues = new List diff --git a/Emby.Server.Implementations/Notifications/Notifications.cs b/Emby.Server.Implementations/Notifications/Notifications.cs index f95b3f701..ac3cc7564 100644 --- a/Emby.Server.Implementations/Notifications/Notifications.cs +++ b/Emby.Server.Implementations/Notifications/Notifications.cs @@ -422,7 +422,7 @@ namespace Emby.Server.Implementations.Notifications { var artists = hasArtist.AllArtists; - if (artists.Count > 0) + if (artists.Length > 0) { name = hasArtist.AllArtists[0] + " - " + name; } @@ -440,7 +440,7 @@ namespace Emby.Server.Implementations.Notifications name = item.SeriesName + " - " + name; } - if (item.Artists != null && item.Artists.Count > 0) + if (item.Artists != null && item.Artists.Length > 0) { name = item.Artists[0] + " - " + name; } diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index 526e62d39..f9fcfdbab 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -215,13 +215,13 @@ namespace Emby.Server.Implementations.Services if (name == null) continue; //thank you ASP.NET var values = request.QueryString.GetValues(name); - if (values.Length == 1) + if (values.Count == 1) { map[name] = values[0]; } else { - for (var i = 0; i < values.Length; i++) + for (var i = 0; i < values.Count; i++) { map[name + (i == 0 ? "" : "#" + i)] = values[i]; } @@ -235,13 +235,13 @@ namespace Emby.Server.Implementations.Services if (name == null) continue; //thank you ASP.NET var values = request.FormData.GetValues(name); - if (values.Length == 1) + if (values.Count == 1) { map[name] = values[0]; } else { - for (var i = 0; i < values.Length; i++) + for (var i = 0; i < values.Count; i++) { map[name + (i == 0 ? "" : "#" + i)] = values[i]; } diff --git a/Emby.Server.Implementations/Sorting/ArtistComparer.cs b/Emby.Server.Implementations/Sorting/ArtistComparer.cs index edb195820..616aff673 100644 --- a/Emby.Server.Implementations/Sorting/ArtistComparer.cs +++ b/Emby.Server.Implementations/Sorting/ArtistComparer.cs @@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.Sorting return string.Empty; } - return audio.Artists.Count == 0 ? null : audio.Artists[0]; + return audio.Artists.Length == 0 ? null : audio.Artists[0]; } /// diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 393fb76e2..75328a39a 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -122,7 +122,10 @@ namespace Emby.Server.Implementations.Updates private readonly ICryptoProvider _cryptographyProvider; - public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config, IFileSystem fileSystem, ICryptoProvider cryptographyProvider) + // netframework or netcore + private readonly string _packageRuntime; + + public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config, IFileSystem fileSystem, ICryptoProvider cryptographyProvider, string packageRuntime) { if (logger == null) { @@ -140,6 +143,7 @@ namespace Emby.Server.Implementations.Updates _config = config; _fileSystem = fileSystem; _cryptographyProvider = cryptographyProvider; + _packageRuntime = packageRuntime; _logger = logger; } @@ -157,7 +161,7 @@ namespace Emby.Server.Implementations.Updates /// Gets all available packages. /// /// Task{List{PackageInfo}}. - public async Task GetAvailablePackages(CancellationToken cancellationToken, + public async Task> GetAvailablePackages(CancellationToken cancellationToken, bool withRegistration = true, string packageType = null, Version applicationVersion = null) @@ -171,7 +175,7 @@ namespace Emby.Server.Implementations.Updates { "systemid", _applicationHost.SystemId } }; - using (var json = await _httpClient.Post("https://www.mb3admin.com/admin/service/package/retrieveall", data, cancellationToken).ConfigureAwait(false)) + using (var json = await _httpClient.Post("https://www.mb3admin.com/admin/service/package/retrieveall?includeAllRuntimes=true", data, cancellationToken).ConfigureAwait(false)) { cancellationToken.ThrowIfCancellationRequested(); @@ -195,7 +199,7 @@ namespace Emby.Server.Implementations.Updates /// /// The cancellation token. /// Task{List{PackageInfo}}. - public async Task GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken) + public async Task> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken) { _logger.Info("Opening {0}", PackageCachePath); try @@ -209,7 +213,7 @@ namespace Emby.Server.Implementations.Updates UpdateCachedPackages(CancellationToken.None, false); } - return packages; + return FilterPackages(packages); } } catch (Exception) @@ -221,7 +225,7 @@ namespace Emby.Server.Implementations.Updates await UpdateCachedPackages(cancellationToken, true).ConfigureAwait(false); using (var stream = _fileSystem.OpenRead(PackageCachePath)) { - return _jsonSerializer.DeserializeFromStream(stream); + return FilterPackages(_jsonSerializer.DeserializeFromStream(stream)); } } @@ -244,7 +248,7 @@ namespace Emby.Server.Implementations.Updates var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions { - Url = "https://www.mb3admin.com/admin/service/MB3Packages.json", + Url = "https://www.mb3admin.com/admin/service/EmbyPackages.json", CancellationToken = cancellationToken, Progress = new SimpleProgress() @@ -280,47 +284,74 @@ namespace Emby.Server.Implementations.Updates return TimeSpan.FromMinutes(3); } - protected PackageInfo[] FilterPackages(List packages) + protected List FilterPackages(IEnumerable packages) { + var list = new List(); foreach (var package in packages) { - package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(GetPackageVersion).ToArray(); + var versions = new List(); + foreach (var version in package.versions) + { + if (string.IsNullOrWhiteSpace(version.sourceUrl)) + { + continue; + } + + if (string.IsNullOrWhiteSpace(version.runtimes) || version.runtimes.IndexOf(_packageRuntime, StringComparison.OrdinalIgnoreCase) == -1) + { + continue; + } + + versions.Add(version); + } + + package.versions = versions + .OrderByDescending(GetPackageVersion) + .ToArray(); + + if (package.versions.Length == 0) + { + continue; + } + + list.Add(package); } // Remove packages with no versions - return packages.Where(p => p.versions.Any()).ToArray(); + return list; } - protected PackageInfo[] FilterPackages(PackageInfo[] packages, string packageType, Version applicationVersion) + protected List FilterPackages(IEnumerable packages, string packageType, Version applicationVersion) { - foreach (var package in packages) - { - package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(GetPackageVersion).ToArray(); - } + var packagesList = FilterPackages(packages); - IEnumerable packagesList = packages; + var returnList = new List(); - if (!string.IsNullOrWhiteSpace(packageType)) - { - packagesList = packagesList.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)); - } + var filterOnPackageType = !string.IsNullOrWhiteSpace(packageType); - // If an app version was supplied, filter the versions for each package to only include supported versions - if (applicationVersion != null) + foreach (var p in packagesList) { - foreach (var package in packages) + if (filterOnPackageType && !string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)) { - package.versions = package.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToArray(); + continue; } - } - // Remove packages with no versions - packagesList = packagesList.Where(p => p.versions.Any()); + // If an app version was supplied, filter the versions for each package to only include supported versions + if (applicationVersion != null) + { + p.versions = p.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToArray(); + } + + if (p.versions.Length == 0) + { + continue; + } + + returnList.Add(p); + } - return packagesList.ToArray(); + return returnList; } /// diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index c7ceb41bc..35ac2b482 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -231,7 +231,7 @@ namespace MediaBrowser.Api SortOrder = request.SortOrder, SortBy = (request.SortBy ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), Filters = request.GetFilters().ToArray(), - Fields = request.GetItemFields().ToArray() + Fields = request.GetItemFields() }, CancellationToken.None).ConfigureAwait(false); diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs index 92128634e..643ecd9c8 100644 --- a/MediaBrowser.Api/ConfigurationService.cs +++ b/MediaBrowser.Api/ConfigurationService.cs @@ -6,7 +6,6 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Serialization; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Controller.IO; diff --git a/MediaBrowser.Api/Devices/DeviceService.cs b/MediaBrowser.Api/Devices/DeviceService.cs index 544960f5f..012f0ddb2 100644 --- a/MediaBrowser.Api/Devices/DeviceService.cs +++ b/MediaBrowser.Api/Devices/DeviceService.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Devices; @@ -143,7 +142,7 @@ namespace MediaBrowser.Api.Devices } else { - var file = Request.Files.First(); + var file = Request.Files.Length == 0 ? null : Request.Files[0]; var task = _deviceManager.AcceptCameraUpload(deviceId, file.InputStream, new LocalFileInfo { diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs index fc8c0edf6..389244aa9 100644 --- a/MediaBrowser.Api/Dlna/DlnaServerService.cs +++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Controller.IO; diff --git a/MediaBrowser.Api/Dlna/DlnaService.cs b/MediaBrowser.Api/Dlna/DlnaService.cs index fa3287ebd..4dd71f446 100644 --- a/MediaBrowser.Api/Dlna/DlnaService.cs +++ b/MediaBrowser.Api/Dlna/DlnaService.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Dlna; +using System.Linq; +using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Dlna; -using System.Linq; using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Dlna diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 318360336..309c7195b 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -556,20 +556,7 @@ namespace MediaBrowser.Api.Images throw new ResourceNotFoundException(string.Format("{0} does not have an image of type {1}", item.Name, request.Type)); } - var supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.ImageEnhancers.Where(i => - { - try - { - return i.Supports(item, request.Type); - } - catch (Exception ex) - { - Logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); - - return false; - } - - }).ToList() : new List(); + var supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.GetSupportedEnhancers(item, request.Type) : new List(); var cropwhitespace = request.Type == ImageType.Logo || request.Type == ImageType.Art diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 56caf884b..47bd46ea5 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -352,7 +352,7 @@ namespace MediaBrowser.Api hasArtists.Artists = request .ArtistItems .Select(i => i.Name) - .ToList(); + .ToArray(); } } diff --git a/MediaBrowser.Api/LocalizationService.cs b/MediaBrowser.Api/LocalizationService.cs index 2c92505b1..56d32fc37 100644 --- a/MediaBrowser.Api/LocalizationService.cs +++ b/MediaBrowser.Api/LocalizationService.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Services; namespace MediaBrowser.Api diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs index 6511d3127..c63712f4c 100644 --- a/MediaBrowser.Api/Movies/CollectionService.cs +++ b/MediaBrowser.Api/Movies/CollectionService.cs @@ -4,7 +4,6 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Model.Collections; using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index 7873c1cd3..3e42026b1 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -426,7 +426,7 @@ namespace MediaBrowser.Api.Movies { var people = _libraryManager.GetPeople(new InternalPeopleQuery { - PersonTypes = new List + PersonTypes = new string[] { PersonType.Director } diff --git a/MediaBrowser.Api/PlaylistService.cs b/MediaBrowser.Api/PlaylistService.cs index 07a976f39..54c995d3d 100644 --- a/MediaBrowser.Api/PlaylistService.cs +++ b/MediaBrowser.Api/PlaylistService.cs @@ -1,11 +1,11 @@ -using MediaBrowser.Controller.Dto; +using System.Linq; +using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Playlists; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Playlists; using MediaBrowser.Model.Querying; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; using MediaBrowser.Model.Extensions; diff --git a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs index 6b10fcb05..6a1502c7e 100644 --- a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs +++ b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs @@ -533,7 +533,7 @@ namespace MediaBrowser.Api.Reports break; case HeaderMetadata.Tracks: - option.Column = (i, r) => this.GetObject>(i, (x) => x.Tracks.ToList(), new List /// The physical locations. - public IEnumerable PhysicalLocations + public string[] PhysicalLocations { get { var paths = string.IsNullOrWhiteSpace(Path) ? new string[] { } : new[] { Path }; - return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations); + return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations).ToArray(); } } diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs index 693b7b221..bab334a6d 100644 --- a/MediaBrowser.Controller/Library/NameExtensions.cs +++ b/MediaBrowser.Controller/Library/NameExtensions.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.Linq; using MediaBrowser.Controller.Extensions; using MediaBrowser.Model.Extensions; @@ -9,25 +7,6 @@ namespace MediaBrowser.Controller.Library { public static class NameExtensions { - public static bool EqualsAny(IEnumerable names, string x) - { - x = NormalizeForComparison(x); - - return names.Any(y => string.Compare(x, y, StringComparison.OrdinalIgnoreCase) == 0); - //return names.Any(y => string.Compare(x, y, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) == 0); - } - - private static string NormalizeForComparison(string name) - { - if (name == null) - { - return string.Empty; - } - - return name; - //return name.RemoveDiacritics(); - } - private static string RemoveDiacritics(string name) { if (name == null) @@ -44,27 +23,4 @@ namespace MediaBrowser.Controller.Library return names.DistinctBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase); } } - - public class DistinctNameComparer : IComparer, IEqualityComparer - { - public int Compare(string x, string y) - { - if (string.IsNullOrWhiteSpace(x) && string.IsNullOrWhiteSpace(y)) - { - return 0; - } - - return string.Compare(x.RemoveDiacritics(), y.RemoveDiacritics(), StringComparison.OrdinalIgnoreCase); - } - - public bool Equals(string x, string y) - { - return Compare(x, y) == 0; - } - - public int GetHashCode(string obj) - { - return (obj ?? string.Empty).GetHashCode(); - } - } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 25bc10dec..c29d73253 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -6,7 +6,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Library; diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 3efbc41f1..1607dbcba 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -9,7 +9,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.LiveTv { diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 2c26d3556..950949f37 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -5,7 +5,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Library; diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 337bb23a4..d957470d3 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -4,7 +4,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; - using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; @@ -73,14 +72,23 @@ namespace MediaBrowser.Controller.Providers return entries; } - public IEnumerable GetFiles(string path) + public List GetFiles(string path) { return GetFiles(path, false); } - public IEnumerable GetFiles(string path, bool clearCache) + public List GetFiles(string path, bool clearCache) { - return GetFileSystemEntries(path, clearCache).Where(i => !i.IsDirectory); + var list = new List(); + var items = GetFileSystemEntries(path, clearCache); + foreach (var item in items) + { + if (!item.IsDirectory) + { + list.Add(item); + } + } + return list; } public FileSystemMetadata GetFile(string path) diff --git a/MediaBrowser.Controller/Providers/IDirectoryService.cs b/MediaBrowser.Controller/Providers/IDirectoryService.cs index 374703948..6f864f4be 100644 --- a/MediaBrowser.Controller/Providers/IDirectoryService.cs +++ b/MediaBrowser.Controller/Providers/IDirectoryService.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Providers public interface IDirectoryService { FileSystemMetadata[] GetFileSystemEntries(string path); - IEnumerable GetFiles(string path); + List GetFiles(string path); FileSystemMetadata GetFile(string path); } } \ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/MetadataResult.cs b/MediaBrowser.Controller/Providers/MetadataResult.cs index 99402a969..5ed55ea16 100644 --- a/MediaBrowser.Controller/Providers/MetadataResult.cs +++ b/MediaBrowser.Controller/Providers/MetadataResult.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using System; using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Controller.Providers { @@ -51,7 +50,15 @@ namespace MediaBrowser.Controller.Providers UserDataList = new List(); } - var userData = UserDataList.FirstOrDefault(i => string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)); + UserItemData userData = null; + + foreach (var i in UserDataList) + { + if (string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)) + { + userData = i; + } + } if (userData == null) { diff --git a/MediaBrowser.Controller/Providers/SongInfo.cs b/MediaBrowser.Controller/Providers/SongInfo.cs index 988e931cd..e3a6f5d37 100644 --- a/MediaBrowser.Controller/Providers/SongInfo.cs +++ b/MediaBrowser.Controller/Providers/SongInfo.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; namespace MediaBrowser.Controller.Providers { @@ -6,11 +5,11 @@ namespace MediaBrowser.Controller.Providers { public string[] AlbumArtists { get; set; } public string Album { get; set; } - public List Artists { get; set; } + public string[] Artists { get; set; } public SongInfo() { - Artists = new List(); + Artists = EmptyStringArray; AlbumArtists = EmptyStringArray; } } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 265f4f544..90c1de2f2 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Session; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Threading; @@ -194,7 +193,19 @@ namespace MediaBrowser.Controller.Session public bool ContainsUser(Guid userId) { - return (UserId ?? Guid.Empty) == userId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); + if ((UserId ?? Guid.Empty) == userId) + { + return true; + } + + foreach (var additionalUser in AdditionalUsers) + { + if (userId == new Guid(additionalUser.UserId)) + { + return true; + } + } + return false; } private readonly object _progressLock = new object(); diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index 881d2a85a..9195a9cd4 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -4,10 +4,8 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; namespace MediaBrowser.LocalMetadata.Images @@ -40,49 +38,50 @@ namespace MediaBrowser.LocalMetadata.Images { var parentPath = _fileSystem.GetDirectoryName(item.Path); - var parentPathFiles = directoryService.GetFiles(parentPath) - .ToList(); + var parentPathFiles = directoryService.GetFiles(parentPath); var nameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(item.Path); return GetFilesFromParentFolder(nameWithoutExtension, parentPathFiles); } - private List GetFilesFromParentFolder(string filenameWithoutExtension, IEnumerable parentPathFiles) + private List GetFilesFromParentFolder(string filenameWithoutExtension, List parentPathFiles) { var thumbName = filenameWithoutExtension + "-thumb"; - return parentPathFiles - .Where(i => - { - if (i.IsDirectory) - { - return false; - } - - if (BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) - { - var currentNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(i); - - if (string.Equals(filenameWithoutExtension, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - if (string.Equals(thumbName, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - } - - return false; - }) - .Select(i => new LocalImageInfo - { - FileInfo = i, - Type = ImageType.Primary - }) - .ToList(); + var list = new List(1); + + foreach (var i in parentPathFiles) + { + if (i.IsDirectory) + { + continue; + } + + if (BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) + { + var currentNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(i); + + if (string.Equals(filenameWithoutExtension, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) + { + list.Add(new LocalImageInfo + { + FileInfo = i, + Type = ImageType.Primary + }); + } + + else if (string.Equals(thumbName, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) + { + list.Add(new LocalImageInfo + { + FileInfo = i, + Type = ImageType.Primary + }); + } + } + } + return list; } } } diff --git a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs index ddfb70321..56a2c271f 100644 --- a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; - using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 8da20c9f5..8bad650b5 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -432,7 +432,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the artists. /// /// The artists. - public List Artists { get; set; } + public string[] Artists { get; set; } /// /// Gets or sets the artist items. diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 8f3f0648d..27920bdf3 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Extensions; using MediaBrowser.Model.MediaInfo; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Session; @@ -91,19 +90,15 @@ namespace MediaBrowser.Model.Dto return; } - var internalStreams = MediaStreams - .Where(i => !i.IsExternal) - .ToList(); - - if (internalStreams.Count == 0) + var bitrate = 0; + foreach (var stream in MediaStreams) { - return; + if (!stream.IsExternal) + { + bitrate += stream.BitRate ?? 0; + } } - var bitrate = internalStreams - .Select(m => m.BitRate ?? 0) - .Sum(); - if (bitrate > 0) { Bitrate = bitrate; diff --git a/MediaBrowser.Model/Extensions/ListHelper.cs b/MediaBrowser.Model/Extensions/ListHelper.cs index cfcb229c8..6fe1793db 100644 --- a/MediaBrowser.Model/Extensions/ListHelper.cs +++ b/MediaBrowser.Model/Extensions/ListHelper.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Model.Extensions { @@ -13,7 +11,14 @@ namespace MediaBrowser.Model.Extensions throw new ArgumentNullException("value"); } - return list.Contains(value, StringComparer.OrdinalIgnoreCase); + foreach (var item in list) + { + if (string.Equals(item, value, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + return false; } public static bool ContainsAnyIgnoreCase(string[] list, string[] values) diff --git a/MediaBrowser.Model/Services/QueryParamCollection.cs b/MediaBrowser.Model/Services/QueryParamCollection.cs index a3e00f587..e13e5feca 100644 --- a/MediaBrowser.Model/Services/QueryParamCollection.cs +++ b/MediaBrowser.Model/Services/QueryParamCollection.cs @@ -58,9 +58,7 @@ namespace MediaBrowser.Model.Services { if (string.IsNullOrWhiteSpace(value)) { - var stringComparison = GetStringComparison(); - - var parameters = this.Where(p => string.Equals(key, p.Name, stringComparison)).ToArray(); + var parameters = GetItems(key); foreach (var p in parameters) { @@ -84,14 +82,6 @@ namespace MediaBrowser.Model.Services Add(key, value); } - /// - /// True if the collection contains a query parameter with the given name. - /// - public bool ContainsKey(string name) - { - return this.Any(p => p.Name == name); - } - /// /// Removes all parameters of the given name. /// @@ -106,16 +96,49 @@ namespace MediaBrowser.Model.Services { var stringComparison = GetStringComparison(); - return this.Where(p => string.Equals(p.Name, name, stringComparison)) - .Select(p => p.Value) - .FirstOrDefault(); + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + return pair.Value; + } + } + + return null; + } + + public virtual List GetItems(string name) + { + var stringComparison = GetStringComparison(); + + var list = new List(); + + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + list.Add(pair); + } + } + + return list; } - public virtual string[] GetValues(string name) + public virtual List GetValues(string name) { var stringComparison = GetStringComparison(); - return this.Where(p => string.Equals(p.Name, name, stringComparison)).Select(p => p.Value).ToArray(); + var list = new List(); + + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + list.Add(pair.Value); + } + } + + return list; } public Dictionary ToDictionary() @@ -134,7 +157,17 @@ namespace MediaBrowser.Model.Services public IEnumerable Keys { - get { return this.Select(i => i.Name); } + get + { + var keys = new string[this.Count]; + + for (var i = 0; i < keys.Length; i++) + { + keys[i] = this[i].Name; + } + + return keys; + } } /// diff --git a/MediaBrowser.Model/Updates/PackageVersionInfo.cs b/MediaBrowser.Model/Updates/PackageVersionInfo.cs index 5e0631b3b..3ac518187 100644 --- a/MediaBrowser.Model/Updates/PackageVersionInfo.cs +++ b/MediaBrowser.Model/Updates/PackageVersionInfo.cs @@ -89,5 +89,7 @@ namespace MediaBrowser.Model.Updates public string targetFilename { get; set; } public string infoUrl { get; set; } + + public string runtimes { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Providers/Books/AudioBookMetadataService.cs b/MediaBrowser.Providers/Books/AudioBookMetadataService.cs index b9e265d22..834ec6cd3 100644 --- a/MediaBrowser.Providers/Books/AudioBookMetadataService.cs +++ b/MediaBrowser.Providers/Books/AudioBookMetadataService.cs @@ -23,9 +23,9 @@ namespace MediaBrowser.Providers.Books var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs b/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs index 2ea0a7ee9..09546e4b6 100644 --- a/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs +++ b/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs @@ -23,9 +23,9 @@ namespace MediaBrowser.Providers.Books var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index 81cd41605..12748a8a7 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -41,11 +41,7 @@ namespace MediaBrowser.Providers.BoxSets if (mergeMetadataSettings) { - // Retain shortcut children - var linkedChildren = sourceItem.LinkedChildren.ToList(); - linkedChildren.AddRange(sourceItem.LinkedChildren.Where(i => i.Type == LinkedChildType.Shortcut)); - - targetItem.LinkedChildren = linkedChildren.ToArray(linkedChildren.Count); + targetItem.LinkedChildren = sourceItem.LinkedChildren; targetItem.Shares = sourceItem.Shares; } } diff --git a/MediaBrowser.Providers/Chapters/ChapterManager.cs b/MediaBrowser.Providers/Chapters/ChapterManager.cs index 3973d3de7..d3e9efd82 100644 --- a/MediaBrowser.Providers/Chapters/ChapterManager.cs +++ b/MediaBrowser.Providers/Chapters/ChapterManager.cs @@ -13,7 +13,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs b/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs index 03bb0f68c..e24547614 100644 --- a/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs b/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs index e6e93e443..ec908095f 100644 --- a/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs +++ b/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs b/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs index 8da88e1c6..a49d42aca 100644 --- a/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/IPriorityQueue.cs b/MediaBrowser.Providers/Manager/IPriorityQueue.cs index 425992b18..23f08a13e 100644 --- a/MediaBrowser.Providers/Manager/IPriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/IPriorityQueue.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs index f4c261a81..879ae1dca 100644 --- a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index b8b603245..a4f2053a9 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Providers.MediaInfo private string GetAudioImagePath(Audio item) { var filename = item.Album ?? string.Empty; - filename += string.Join(",", item.Artists.ToArray(item.Artists.Count)); + filename += string.Join(",", item.Artists); if (!string.IsNullOrWhiteSpace(item.Album)) { diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs index fb1fed8b3..b0785298b 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs @@ -141,7 +141,7 @@ namespace MediaBrowser.Providers.MediaInfo } audio.Album = data.Album; - audio.Artists = data.Artists.ToList(); + audio.Artists = data.Artists; audio.AlbumArtists = data.AlbumArtists; audio.IndexNumber = data.IndexNumber; audio.ParentIndexNumber = data.ParentIndexNumber; diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.cs index fe39a841e..4230c517a 100644 --- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs +++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs @@ -106,7 +106,7 @@ namespace MediaBrowser.Providers.Music .SelectMany(i => i.Artists) .Distinct(StringComparer.OrdinalIgnoreCase) .OrderBy(i => i) - .ToList(); + .ToArray(); if (!item.Artists.SequenceEqual(artists, StringComparer.OrdinalIgnoreCase)) { @@ -158,7 +158,7 @@ namespace MediaBrowser.Providers.Music var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { targetItem.Artists = sourceItem.Artists; } diff --git a/MediaBrowser.Providers/Music/ArtistMetadataService.cs b/MediaBrowser.Providers/Music/ArtistMetadataService.cs index c8008ba1e..0ff161576 100644 --- a/MediaBrowser.Providers/Music/ArtistMetadataService.cs +++ b/MediaBrowser.Providers/Music/ArtistMetadataService.cs @@ -31,7 +31,7 @@ namespace MediaBrowser.Providers.Music }) : item.GetRecursiveChildren(i => i is IHasArtist && !i.IsFolder); - var currentList = item.Genres.ToList(); + var currentList = item.Genres; item.Genres = taggedItems.SelectMany(i => i.Genres) .DistinctNames() diff --git a/MediaBrowser.Providers/Music/AudioMetadataService.cs b/MediaBrowser.Providers/Music/AudioMetadataService.cs index 68a4fcd7c..f02eae19f 100644 --- a/MediaBrowser.Providers/Music/AudioMetadataService.cs +++ b/MediaBrowser.Providers/Music/AudioMetadataService.cs @@ -21,9 +21,9 @@ namespace MediaBrowser.Providers.Music var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs b/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs index 27c6deb74..28504dbd7 100644 --- a/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs +++ b/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs @@ -28,9 +28,9 @@ namespace MediaBrowser.Providers.Music targetItem.Album = sourceItem.Album; } - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } } diff --git a/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs b/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs index dccef3a09..d39d3baf5 100644 --- a/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs +++ b/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs @@ -42,12 +42,9 @@ namespace MediaBrowser.Providers.Playlists { if (!item.IsLocked && !item.LockedFields.Contains(MetadataFields.Genres)) { - var items = item.GetLinkedChildren() - .ToList(); - - var currentList = item.Genres.ToList(); + var currentList = item.Genres; - item.Genres = items.SelectMany(i => i.Genres) + item.Genres = item.GetLinkedChildren().SelectMany(i => i.Genres) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 73a568ca9..443699b5a 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -261,9 +261,10 @@ namespace MediaBrowser.Server.Mono { var args = Environment.GetCommandLineArgs() .Skip(1) - .Select(NormalizeCommandLineArgument); + .Select(NormalizeCommandLineArgument) + .ToArray(); - commandLineArgsString = string.Join(" ", args.ToArray()); + commandLineArgsString = string.Join(" ", args); } _logger.Info("Executable: {0}", module); diff --git a/MediaBrowser.ServerApplication/Native/LoopUtil.cs b/MediaBrowser.ServerApplication/Native/LoopUtil.cs index 7c7471231..0efdba389 100644 --- a/MediaBrowser.ServerApplication/Native/LoopUtil.cs +++ b/MediaBrowser.ServerApplication/Native/LoopUtil.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.XbmcMetadata/EntryPoint.cs b/MediaBrowser.XbmcMetadata/EntryPoint.cs index ac5313a29..b1c687a6e 100644 --- a/MediaBrowser.XbmcMetadata/EntryPoint.cs +++ b/MediaBrowser.XbmcMetadata/EntryPoint.cs @@ -8,7 +8,6 @@ using MediaBrowser.Model.Logging; using MediaBrowser.XbmcMetadata.Configuration; using MediaBrowser.XbmcMetadata.Savers; using System; -using System.Linq; using MediaBrowser.Controller.Dto; namespace MediaBrowser.XbmcMetadata diff --git a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs index f9ca238c7..85f9f92ba 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.Linq; +using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Providers; @@ -81,7 +82,9 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val) && movie != null) { - movie.Artists.Add(val); + var list = movie.Artists.ToList(); + list.Add(val); + movie.Artists = list.ToArray(); } break; diff --git a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs index ec53b3bc4..f9f9c9b98 100644 --- a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs @@ -57,10 +57,9 @@ namespace MediaBrowser.XbmcMetadata.Savers private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - private void AddTracks(IEnumerable /// The to validate. - System.Collections.Generic.IEnumerable GetValidationErrors(SsdpRootDevice device); + System.Collections.Generic.List GetValidationErrors(SsdpRootDevice device); /// /// Returns an enumerable set of strings, each one being a description of an invalid property on the specified device. /// /// The to validate. - System.Collections.Generic.IEnumerable GetValidationErrors(SsdpDevice device); + System.Collections.Generic.List GetValidationErrors(SsdpDevice device); /// /// Validates the specified device and throws an if there are any validation errors. diff --git a/RSSDP/RequestReceivedEventArgs.cs b/RSSDP/RequestReceivedEventArgs.cs index 03c059634..f4e367760 100644 --- a/RSSDP/RequestReceivedEventArgs.cs +++ b/RSSDP/RequestReceivedEventArgs.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Text; diff --git a/RSSDP/ResponseReceivedEventArgs.cs b/RSSDP/ResponseReceivedEventArgs.cs index c983fa204..f67d5da90 100644 --- a/RSSDP/ResponseReceivedEventArgs.cs +++ b/RSSDP/ResponseReceivedEventArgs.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Text; diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs index 91004b76f..a4be24ebf 100644 --- a/RSSDP/SsdpCommunicationsServer.cs +++ b/RSSDP/SsdpCommunicationsServer.cs @@ -364,7 +364,7 @@ namespace Rssdp.Infrastructure if (_enableMultiSocketBinding) { - foreach (var address in _networkManager.GetLocalIpAddresses().ToList()) + foreach (var address in _networkManager.GetLocalIpAddresses()) { try { diff --git a/RSSDP/SsdpConstants.cs b/RSSDP/SsdpConstants.cs index c839d9e0b..87f01f9e0 100644 --- a/RSSDP/SsdpConstants.cs +++ b/RSSDP/SsdpConstants.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDevice.cs b/RSSDP/SsdpDevice.cs index a595742d0..cda11f0a4 100644 --- a/RSSDP/SsdpDevice.cs +++ b/RSSDP/SsdpDevice.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; @@ -283,7 +282,7 @@ namespace Rssdp /// /// /// - public IEnumerable Devices + public IList Devices { get; private set; @@ -466,7 +465,7 @@ namespace Rssdp private static void WriteIcons(XmlWriter writer, SsdpDevice device) { - if (device.Icons.Any()) + if (device.Icons.Count > 0) { writer.WriteStartElement("iconList"); @@ -489,7 +488,7 @@ namespace Rssdp private void WriteChildDevices(XmlWriter writer, SsdpDevice parentDevice) { - if (parentDevice.Devices.Any()) + if (parentDevice.Devices.Count > 0) { writer.WriteStartElement("deviceList"); diff --git a/RSSDP/SsdpDeviceExtensions.cs b/RSSDP/SsdpDeviceExtensions.cs index 0ad710a6b..6e1b45646 100644 --- a/RSSDP/SsdpDeviceExtensions.cs +++ b/RSSDP/SsdpDeviceExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpDeviceIcon.cs b/RSSDP/SsdpDeviceIcon.cs index 4ffda58ff..3ed707c80 100644 --- a/RSSDP/SsdpDeviceIcon.cs +++ b/RSSDP/SsdpDeviceIcon.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDeviceLocator.cs b/RSSDP/SsdpDeviceLocator.cs index 3ea17237d..8fe4d4a14 100644 --- a/RSSDP/SsdpDeviceLocator.cs +++ b/RSSDP/SsdpDeviceLocator.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using MediaBrowser.Model.Net; using MediaBrowser.Model.Threading; diff --git a/RSSDP/SsdpDeviceLocatorBase.cs b/RSSDP/SsdpDeviceLocatorBase.cs index 1adb95cdf..d1eaef88a 100644 --- a/RSSDP/SsdpDeviceLocatorBase.cs +++ b/RSSDP/SsdpDeviceLocatorBase.cs @@ -127,7 +127,7 @@ namespace Rssdp.Infrastructure } catch (Exception ex) { - + } } @@ -543,17 +543,9 @@ namespace Rssdp.Infrastructure } } - private IEnumerable GetUnexpiredDevices() - { - lock (_Devices) - { - return (from device in _Devices where !device.IsExpired() select device).ToArray(); - } - } - private bool DeviceDied(string deviceUsn, bool expired) { - IEnumerable existingDevices = null; + List existingDevices = null; lock (_Devices) { existingDevices = FindExistingDeviceNotifications(_Devices, deviceUsn); @@ -565,7 +557,7 @@ namespace Rssdp.Infrastructure } } - if (existingDevices != null && existingDevices.Any()) + if (existingDevices != null && existingDevices.Count > 0) { foreach (var removedDevice in existingDevices) { @@ -591,12 +583,29 @@ namespace Rssdp.Infrastructure private static DiscoveredSsdpDevice FindExistingDeviceNotification(IEnumerable devices, string notificationType, string usn) { - return (from d in devices where d.NotificationType == notificationType && d.Usn == usn select d).FirstOrDefault(); + foreach (var d in devices) + { + if (d.NotificationType == notificationType && d.Usn == usn) + { + return d; + } + } + return null; } - private static IEnumerable FindExistingDeviceNotifications(IList devices, string usn) + private static List FindExistingDeviceNotifications(IList devices, string usn) { - return (from d in devices where d.Usn == usn select d).ToArray(); + var list = new List(); + + foreach (var d in devices) + { + if (d.Usn == usn) + { + list.Add(d); + } + } + + return list; } #endregion diff --git a/RSSDP/SsdpDeviceProperties.cs b/RSSDP/SsdpDeviceProperties.cs index 850dfb0ba..ae5309da5 100644 --- a/RSSDP/SsdpDeviceProperties.cs +++ b/RSSDP/SsdpDeviceProperties.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpDeviceProperty.cs b/RSSDP/SsdpDeviceProperty.cs index 3a8dd2ec7..3abcfb9aa 100644 --- a/RSSDP/SsdpDeviceProperty.cs +++ b/RSSDP/SsdpDeviceProperty.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDevicePublisher.cs b/RSSDP/SsdpDevicePublisher.cs index 1c17c7837..2aa143775 100644 --- a/RSSDP/SsdpDevicePublisher.cs +++ b/RSSDP/SsdpDevicePublisher.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using MediaBrowser.Model.Net; using MediaBrowser.Model.Threading; diff --git a/RSSDP/SsdpEmbeddedDevice.cs b/RSSDP/SsdpEmbeddedDevice.cs index c03106b2d..28948f950 100644 --- a/RSSDP/SsdpEmbeddedDevice.cs +++ b/RSSDP/SsdpEmbeddedDevice.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpRootDevice.cs b/RSSDP/SsdpRootDevice.cs index faf851bcb..5b7d0f454 100644 --- a/RSSDP/SsdpRootDevice.cs +++ b/RSSDP/SsdpRootDevice.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Xml; using Rssdp.Infrastructure; diff --git a/RSSDP/UPnP10DeviceValidator.cs b/RSSDP/UPnP10DeviceValidator.cs index f802b7639..2a8a9ccd2 100644 --- a/RSSDP/UPnP10DeviceValidator.cs +++ b/RSSDP/UPnP10DeviceValidator.cs @@ -26,11 +26,11 @@ namespace Rssdp.Infrastructure /// The to validate. /// Thrown if the argument is null. /// A non-null enumerable set of strings, empty if there are no validation errors, otherwise each string represents a discrete problem. - public IEnumerable GetValidationErrors(SsdpRootDevice device) + public List GetValidationErrors(SsdpRootDevice device) { if (device == null) throw new ArgumentNullException("device"); - var retVal = GetValidationErrors((SsdpDevice)device) as IList; + var retVal = GetValidationErrors((SsdpDevice)device); if (device.Location == null) retVal.Add("Location cannot be null."); @@ -49,7 +49,7 @@ namespace Rssdp.Infrastructure /// The to validate. /// Thrown if the argument is null. /// A non-null enumerable set of strings, empty if there are no validation errors, otherwise each string represents a discrete problem. - public IEnumerable GetValidationErrors(SsdpDevice device) + public List GetValidationErrors(SsdpDevice device) { if (device == null) throw new ArgumentNullException("device"); @@ -110,7 +110,7 @@ namespace Rssdp.Infrastructure if (String.IsNullOrEmpty(device.ModelName)) retVal.Add("ModelName is required."); - if (device.Icons.Any()) + if (device.Icons.Count > 0) ValidateIcons(device, retVal); ValidateChildDevices(device, retVal); @@ -127,7 +127,7 @@ namespace Rssdp.Infrastructure public void ThrowIfDeviceInvalid(SsdpDevice device) { var errors = this.GetValidationErrors(device); - if (errors != null && errors.Any()) throw new InvalidOperationException("Invalid device settings : " + String.Join(Environment.NewLine, errors)); + if (errors != null && errors.Count > 0) throw new InvalidOperationException("Invalid device settings : " + String.Join(Environment.NewLine, errors)); } #endregion diff --git a/SocketHttpListener/Net/BoundaryType.cs b/SocketHttpListener/Net/BoundaryType.cs index c3ac00c0f..f1e799f63 100644 --- a/SocketHttpListener/Net/BoundaryType.cs +++ b/SocketHttpListener/Net/BoundaryType.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/CookieHelper.cs b/SocketHttpListener/Net/CookieHelper.cs index 470507d6b..a32131956 100644 --- a/SocketHttpListener/Net/CookieHelper.cs +++ b/SocketHttpListener/Net/CookieHelper.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/EndPointManager.cs b/SocketHttpListener/Net/EndPointManager.cs index 6a00ed360..ddb110ec1 100644 --- a/SocketHttpListener/Net/EndPointManager.cs +++ b/SocketHttpListener/Net/EndPointManager.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Reflection; using System.Threading.Tasks; @@ -83,7 +82,9 @@ namespace SocketHttpListener.Net { try { - addr = (await networkManager.GetHostAddressesAsync(host).ConfigureAwait(false)).FirstOrDefault() ?? + var all = (await networkManager.GetHostAddressesAsync(host).ConfigureAwait(false)); + + addr = (all.Length == 0 ? null : all[0]) ?? GetIpAnyAddress(listener); } catch diff --git a/SocketHttpListener/Net/EntitySendFormat.cs b/SocketHttpListener/Net/EntitySendFormat.cs index 6e585bdc9..9caee3e11 100644 --- a/SocketHttpListener/Net/EntitySendFormat.cs +++ b/SocketHttpListener/Net/EntitySendFormat.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs index 83fcc09ca..34953b569 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpListenerResponse.cs b/SocketHttpListener/Net/HttpListenerResponse.cs index fc57e8485..1cbd6165e 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpRequestStream.Managed.cs b/SocketHttpListener/Net/HttpRequestStream.Managed.cs index 92f4bbb02..c9c148b15 100644 --- a/SocketHttpListener/Net/HttpRequestStream.Managed.cs +++ b/SocketHttpListener/Net/HttpRequestStream.Managed.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.ExceptionServices; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpRequestStream.cs b/SocketHttpListener/Net/HttpRequestStream.cs index c54da44a1..f10c04a4f 100644 --- a/SocketHttpListener/Net/HttpRequestStream.cs +++ b/SocketHttpListener/Net/HttpRequestStream.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs index 116c3280a..b700c293d 100644 --- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs +++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; using System.Net.Sockets; using System.Runtime.ExceptionServices; diff --git a/SocketHttpListener/Net/HttpResponseStream.cs b/SocketHttpListener/Net/HttpResponseStream.cs index f7140be66..5b7fa417f 100644 --- a/SocketHttpListener/Net/HttpResponseStream.cs +++ b/SocketHttpListener/Net/HttpResponseStream.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpStatusDescription.cs b/SocketHttpListener/Net/HttpStatusDescription.cs index 8d490c511..9cc4a8e8c 100644 --- a/SocketHttpListener/Net/HttpStatusDescription.cs +++ b/SocketHttpListener/Net/HttpStatusDescription.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/UriScheme.cs b/SocketHttpListener/Net/UriScheme.cs index eb13619c9..35b01e0e5 100644 --- a/SocketHttpListener/Net/UriScheme.cs +++ b/SocketHttpListener/Net/UriScheme.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs index 66e159ccb..d82dc6816 100644 --- a/SocketHttpListener/Net/WebHeaderCollection.cs +++ b/SocketHttpListener/Net/WebHeaderCollection.cs @@ -131,13 +131,13 @@ namespace SocketHttpListener.Net base.Add(headerName, headerValue); } - internal string[] GetValues_internal(string header, bool split) + internal List GetValues_internal(string header, bool split) { if (header == null) throw new ArgumentNullException("header"); - string[] values = base.GetValues(header); - if (values == null || values.Length == 0) + var values = base.GetValues(header); + if (values == null || values.Count == 0) return null; if (split && IsMultiValue(header)) @@ -155,7 +155,7 @@ namespace SocketHttpListener.Net if (separated == null) { - separated = new List(values.Length + 1); + separated = new List(values.Count + 1); foreach (var v in values) { if (v == value) @@ -177,13 +177,13 @@ namespace SocketHttpListener.Net } if (separated != null) - return separated.ToArray(separated.Count); + return separated; } return values; } - public override string[] GetValues(string header) + public override List GetValues(string header) { return GetValues_internal(header, true); } diff --git a/SocketHttpListener/Net/WebHeaderEncoding.cs b/SocketHttpListener/Net/WebHeaderEncoding.cs index 64330c1b4..4a080179e 100644 --- a/SocketHttpListener/Net/WebHeaderEncoding.cs +++ b/SocketHttpListener/Net/WebHeaderEncoding.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Primitives/ICertificate.cs b/SocketHttpListener/Primitives/ICertificate.cs index 1289da13d..ec21e9445 100644 --- a/SocketHttpListener/Primitives/ICertificate.cs +++ b/SocketHttpListener/Primitives/ICertificate.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Primitives/IStreamFactory.cs b/SocketHttpListener/Primitives/IStreamFactory.cs index 57e21e31b..4b623b940 100644 --- a/SocketHttpListener/Primitives/IStreamFactory.cs +++ b/SocketHttpListener/Primitives/IStreamFactory.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; using MediaBrowser.Model.Net; diff --git a/SocketHttpListener/Primitives/ITextEncoding.cs b/SocketHttpListener/Primitives/ITextEncoding.cs index b10145687..2c25a308c 100644 --- a/SocketHttpListener/Primitives/ITextEncoding.cs +++ b/SocketHttpListener/Primitives/ITextEncoding.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; using MediaBrowser.Model.Text; -- cgit v1.2.3 From e287e3a50d0f83a43905c17434e928fd6d754d9f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 26 Aug 2017 20:32:33 -0400 Subject: remove async when there's nothing to await --- .../Activity/ActivityLogEntryPoint.cs | 12 ++-- .../Activity/ActivityManager.cs | 6 +- .../Activity/ActivityRepository.cs | 7 +-- Emby.Server.Implementations/ApplicationHost.cs | 2 +- .../Channels/ChannelManager.cs | 6 +- .../Collections/CollectionManager.cs | 2 +- .../Data/SqliteDisplayPreferencesRepository.cs | 9 ++- .../Data/SqliteItemRepository.cs | 31 ++++------ .../Data/SqliteUserDataRepository.cs | 15 +++-- .../Data/SqliteUserRepository.cs | 5 +- .../Library/LibraryManager.cs | 39 ++++++------- .../Library/UserDataManager.cs | 12 ++-- Emby.Server.Implementations/Library/UserManager.cs | 68 +++++++++++----------- .../Library/UserViewManager.cs | 16 ++--- .../LiveTv/LiveTvManager.cs | 6 +- .../MediaEncoder/EncodingManager.cs | 2 +- .../Playlists/PlaylistManager.cs | 2 +- .../Security/AuthenticationRepository.cs | 7 +-- .../Session/SessionManager.cs | 42 ++++++------- .../Social/SharingManager.cs | 8 +-- .../Social/SharingRepository.cs | 6 +- MediaBrowser.Api/DisplayPreferencesService.cs | 4 +- MediaBrowser.Api/ItemUpdateService.cs | 2 +- MediaBrowser.Api/Library/LibraryService.cs | 8 +-- MediaBrowser.Api/Session/SessionsService.cs | 7 +-- MediaBrowser.Api/Social/SharingService.cs | 5 +- MediaBrowser.Api/StartupWizardService.cs | 2 +- MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 24 ++++---- MediaBrowser.Api/UserService.cs | 57 +++++++----------- .../Chapters/IChapterManager.cs | 4 +- MediaBrowser.Controller/Entities/BaseItem.cs | 8 +-- MediaBrowser.Controller/Entities/Folder.cs | 24 ++++---- MediaBrowser.Controller/Entities/User.cs | 15 ++--- MediaBrowser.Controller/Library/ILibraryManager.cs | 15 ++--- .../Library/IUserDataManager.cs | 7 +-- MediaBrowser.Controller/Library/IUserManager.cs | 16 ++--- .../Persistence/IDisplayPreferencesRepository.cs | 7 +-- .../Persistence/IItemRepository.cs | 24 +++----- .../Persistence/IUserDataRepository.cs | 7 +-- .../Persistence/IUserRepository.cs | 5 +- .../Security/IAuthenticationRepository.cs | 5 +- MediaBrowser.Controller/Session/ISessionManager.cs | 6 +- MediaBrowser.Model/Activity/IActivityManager.cs | 3 +- MediaBrowser.Model/Activity/IActivityRepository.cs | 3 +- MediaBrowser.Model/Social/ISharingManager.cs | 2 +- MediaBrowser.Model/Social/ISharingRepository.cs | 7 +-- MediaBrowser.Providers/Chapters/ChapterManager.cs | 6 +- MediaBrowser.Providers/Manager/MetadataService.cs | 15 +++-- .../MediaInfo/FFProbeAudioInfo.cs | 14 ++--- .../MediaInfo/FFProbeVideoInfo.cs | 12 ++-- MediaBrowser.Providers/TV/DummySeasonProvider.cs | 6 +- .../TV/MissingEpisodeProvider.cs | 6 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 54 files changed, 287 insertions(+), 348 deletions(-) (limited to 'Emby.Server.Implementations/Library') diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs index 702917832..1b6daca73 100644 --- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs +++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs @@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Activity { // Don't report theme song or local trailer playback return; - } + } if (e.Users.Count == 0) { @@ -160,8 +160,8 @@ namespace Emby.Server.Implementations.Activity { // Don't report theme song or local trailer playback return; - } - + } + if (e.Users.Count == 0) { return; @@ -416,7 +416,7 @@ namespace Emby.Server.Implementations.Activity { return; } - + var time = result.EndTimeUtc - result.StartTimeUtc; var runningTime = string.Format(_localization.GetLocalizedString("LabelRunningTimeValue"), ToUserFriendlyString(time)); @@ -444,11 +444,11 @@ namespace Emby.Server.Implementations.Activity } } - private async void CreateLogEntry(ActivityLogEntry entry) + private void CreateLogEntry(ActivityLogEntry entry) { try { - await _activityManager.Create(entry).ConfigureAwait(false); + _activityManager.Create(entry); } catch { diff --git a/Emby.Server.Implementations/Activity/ActivityManager.cs b/Emby.Server.Implementations/Activity/ActivityManager.cs index b6095f082..9a3f1ae47 100644 --- a/Emby.Server.Implementations/Activity/ActivityManager.cs +++ b/Emby.Server.Implementations/Activity/ActivityManager.cs @@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.Activity public class ActivityManager : IActivityManager { public event EventHandler> EntryCreated; - + private readonly IActivityRepository _repo; private readonly ILogger _logger; private readonly IUserManager _userManager; @@ -25,12 +25,12 @@ namespace Emby.Server.Implementations.Activity _userManager = userManager; } - public async Task Create(ActivityLogEntry entry) + public void Create(ActivityLogEntry entry) { entry.Id = Guid.NewGuid().ToString("N"); entry.Date = DateTime.UtcNow; - await _repo.Create(entry).ConfigureAwait(false); + _repo.Create(entry); EventHelper.FireEventIfNotNull(EntryCreated, this, new GenericEventArgs(entry), _logger); } diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs index 7720f8f2f..3dcc50ba3 100644 --- a/Emby.Server.Implementations/Activity/ActivityRepository.cs +++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Threading.Tasks; using Emby.Server.Implementations.Data; using MediaBrowser.Controller; using MediaBrowser.Model.Activity; @@ -41,12 +40,12 @@ namespace Emby.Server.Implementations.Activity private const string BaseActivitySelectText = "select Id, Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity from ActivityLogEntries"; - public Task Create(ActivityLogEntry entry) + public void Create(ActivityLogEntry entry) { - return Update(entry); + Update(entry); } - public async Task Update(ActivityLogEntry entry) + public void Update(ActivityLogEntry entry) { if (entry == null) { diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 88dd47538..70ec37a3b 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1048,7 +1048,7 @@ namespace Emby.Server.Implementations SetStaticProperties(); - await ((UserManager)UserManager).Initialize().ConfigureAwait(false); + ((UserManager)UserManager).Initialize(); } protected virtual string PackageRuntime diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index d8d69a62e..fcc637b25 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -429,7 +429,7 @@ namespace Emby.Server.Implementations.Channels if (isNew) { - await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItem(item, cancellationToken); } else if (forceUpdate) { @@ -1388,11 +1388,11 @@ namespace Emby.Server.Implementations.Channels if (isNew) { - await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItem(item, cancellationToken); if (info.People != null && info.People.Count > 0) { - await _libraryManager.UpdatePeople(item, info.People ?? new List()).ConfigureAwait(false); + _libraryManager.UpdatePeople(item, info.People ?? new List()); } } else if (forceUpdate) diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 0fc8fdc48..2e884e729 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -90,7 +90,7 @@ namespace Emby.Server.Implementations.Collections }).ToList() }; - await parentFolder.AddChild(collection, CancellationToken.None).ConfigureAwait(false); + parentFolder.AddChild(collection, CancellationToken.None); if (options.ItemIdList.Length > 0) { diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 4118bd1b2..89664d158 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Persistence; @@ -75,7 +74,7 @@ namespace Emby.Server.Implementations.Data /// The cancellation token. /// Task. /// item - public async Task SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken) + public void SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken) { if (displayPreferences == null) { @@ -123,7 +122,7 @@ namespace Emby.Server.Implementations.Data /// The cancellation token. /// Task. /// item - public async Task SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, CancellationToken cancellationToken) + public void SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, CancellationToken cancellationToken) { if (displayPreferences == null) { @@ -226,9 +225,9 @@ namespace Emby.Server.Implementations.Data } } - public Task SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken) + public void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken) { - return SaveDisplayPreferences(displayPreferences, new Guid(userId), client, cancellationToken); + SaveDisplayPreferences(displayPreferences, new Guid(userId), client, cancellationToken); } public DisplayPreferences GetDisplayPreferences(string displayPreferencesId, string userId, string client) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index ff1d217e5..74e009bd9 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -132,8 +132,7 @@ namespace Emby.Server.Implementations.Data /// /// Opens the connection to the database /// - /// Task. - public async Task Initialize(SqliteUserDataRepository userDataRepo) + public void Initialize(SqliteUserDataRepository userDataRepo) { using (var connection = CreateConnection()) { @@ -600,16 +599,15 @@ namespace Emby.Server.Implementations.Data /// /// The item. /// The cancellation token. - /// Task. /// item - public Task SaveItem(BaseItem item, CancellationToken cancellationToken) + public void SaveItem(BaseItem item, CancellationToken cancellationToken) { if (item == null) { throw new ArgumentNullException("item"); } - return SaveItems(new List { item }, cancellationToken); + SaveItems(new List { item }, cancellationToken); } /// @@ -617,13 +615,12 @@ namespace Emby.Server.Implementations.Data /// /// The items. /// The cancellation token. - /// Task. /// /// items /// or /// cancellationToken /// - public async Task SaveItems(List items, CancellationToken cancellationToken) + public void SaveItems(List items, CancellationToken cancellationToken) { if (items == null) { @@ -1959,22 +1956,18 @@ namespace Emby.Server.Implementations.Data /// Gets the critic reviews. /// /// The item id. - /// Task{IEnumerable{ItemReview}}. public List GetCriticReviews(Guid itemId) { return new List(); } - private readonly Task _cachedTask = Task.FromResult(true); /// /// Saves the critic reviews. /// /// The item id. /// The critic reviews. - /// Task. - public Task SaveCriticReviews(Guid itemId, IEnumerable criticReviews) + public void SaveCriticReviews(Guid itemId, IEnumerable criticReviews) { - return _cachedTask; } /// @@ -2079,7 +2072,7 @@ namespace Emby.Server.Implementations.Data /// /// Saves the chapters. /// - public async Task SaveChapters(Guid id, List chapters) + public void SaveChapters(Guid id, List chapters) { CheckDisposed(); @@ -4654,12 +4647,12 @@ namespace Emby.Server.Implementations.Data typeof(AggregateFolder) }; - public async Task UpdateInheritedValues(CancellationToken cancellationToken) + public void UpdateInheritedValues(CancellationToken cancellationToken) { - await UpdateInheritedTags(cancellationToken).ConfigureAwait(false); + UpdateInheritedTags(cancellationToken); } - private async Task UpdateInheritedTags(CancellationToken cancellationToken) + private void UpdateInheritedTags(CancellationToken cancellationToken) { var newValues = new List>(); @@ -4754,7 +4747,7 @@ limit 100"; return new[] { value }.Where(IsValidType); } - public async Task DeleteItem(Guid id, CancellationToken cancellationToken) + public void DeleteItem(Guid id, CancellationToken cancellationToken) { if (id == Guid.Empty) { @@ -5485,7 +5478,7 @@ limit 100"; } } - public async Task UpdatePeople(Guid itemId, List people) + public void UpdatePeople(Guid itemId, List people) { if (itemId == Guid.Empty) { @@ -5615,7 +5608,7 @@ limit 100"; } } - public async Task SaveMediaStreams(Guid id, List streams, CancellationToken cancellationToken) + public void SaveMediaStreams(Guid id, List streams, CancellationToken cancellationToken) { CheckDisposed(); diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index bf6388f5d..ef1d7ba44 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Persistence; @@ -153,7 +152,7 @@ namespace Emby.Server.Implementations.Data /// userId /// or /// userDataId - public Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) + public void SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) { if (userData == null) { @@ -168,10 +167,10 @@ namespace Emby.Server.Implementations.Data throw new ArgumentNullException("key"); } - return PersistUserData(userId, key, userData, cancellationToken); + PersistUserData(userId, key, userData, cancellationToken); } - public Task SaveAllUserData(Guid userId, IEnumerable userData, CancellationToken cancellationToken) + public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken) { if (userData == null) { @@ -182,7 +181,7 @@ namespace Emby.Server.Implementations.Data throw new ArgumentNullException("userId"); } - return PersistAllUserData(userId, userData.ToList(), cancellationToken); + PersistAllUserData(userId, userData, cancellationToken); } /// @@ -193,7 +192,7 @@ namespace Emby.Server.Implementations.Data /// The user data. /// The cancellation token. /// Task. - public async Task PersistUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) + public void PersistUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -264,7 +263,7 @@ namespace Emby.Server.Implementations.Data /// /// Persist all user data for the specified user /// - private async Task PersistAllUserData(Guid userId, List userDataList, CancellationToken cancellationToken) + private void PersistAllUserData(Guid userId, UserItemData[] userDataList, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -349,7 +348,7 @@ namespace Emby.Server.Implementations.Data /// /// /// - public IEnumerable GetAllUserData(Guid userId) + public List GetAllUserData(Guid userId) { if (userId == Guid.Empty) { diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs index 29959bcab..b65996e40 100644 --- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Controller; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Persistence; @@ -72,7 +71,7 @@ namespace Emby.Server.Implementations.Data /// The cancellation token. /// Task. /// user - public async Task SaveUser(User user, CancellationToken cancellationToken) + public void SaveUser(User user, CancellationToken cancellationToken) { if (user == null) { @@ -139,7 +138,7 @@ namespace Emby.Server.Implementations.Data /// The cancellation token. /// Task. /// user - public async Task DeleteUser(User user, CancellationToken cancellationToken) + public void DeleteUser(User user, CancellationToken cancellationToken) { if (user == null) { diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 1bfc93e79..57e42985d 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -461,10 +461,10 @@ namespace Emby.Server.Implementations.Library parent.RemoveChild(item); } - await ItemRepository.DeleteItem(item.Id, CancellationToken.None).ConfigureAwait(false); + ItemRepository.DeleteItem(item.Id, CancellationToken.None); foreach (var child in children) { - await ItemRepository.DeleteItem(child.Id, CancellationToken.None).ConfigureAwait(false); + ItemRepository.DeleteItem(child.Id, CancellationToken.None); } BaseItem removed; @@ -997,8 +997,7 @@ namespace Emby.Server.Implementations.Library Path = path }; - var task = CreateItem(item, CancellationToken.None); - Task.WaitAll(task); + CreateItem(item, CancellationToken.None); } return item; @@ -1170,7 +1169,7 @@ namespace Emby.Server.Implementations.Library progress.Report(percent * 100); } - await ItemRepository.UpdateInheritedValues(cancellationToken).ConfigureAwait(false); + ItemRepository.UpdateInheritedValues(cancellationToken); progress.Report(100); } @@ -1812,9 +1811,9 @@ namespace Emby.Server.Implementations.Library /// The item. /// The cancellation token. /// Task. - public Task CreateItem(BaseItem item, CancellationToken cancellationToken) + public void CreateItem(BaseItem item, CancellationToken cancellationToken) { - return CreateItems(new[] { item }, cancellationToken); + CreateItems(new[] { item }, cancellationToken); } /// @@ -1823,11 +1822,11 @@ namespace Emby.Server.Implementations.Library /// The items. /// The cancellation token. /// Task. - public async Task CreateItems(IEnumerable items, CancellationToken cancellationToken) + public void CreateItems(IEnumerable items, CancellationToken cancellationToken) { var list = items.ToList(); - await ItemRepository.SaveItems(list, cancellationToken).ConfigureAwait(false); + ItemRepository.SaveItems(list, cancellationToken); foreach (var item in list) { @@ -1870,7 +1869,7 @@ namespace Emby.Server.Implementations.Library var logName = item.LocationType == LocationType.Remote ? item.Name ?? item.Path : item.Path ?? item.Name; _logger.Debug("Saving {0} to database.", logName); - await ItemRepository.SaveItem(item, cancellationToken).ConfigureAwait(false); + ItemRepository.SaveItem(item, cancellationToken); RegisterItem(item); @@ -2067,7 +2066,7 @@ namespace Emby.Server.Implementations.Library private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24); //private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromMinutes(1); - public Task GetNamedView(User user, + public UserView GetNamedView(User user, string name, string viewType, string sortName, @@ -2105,7 +2104,7 @@ namespace Emby.Server.Implementations.Library ForcedSortName = sortName }; - await CreateItem(item, cancellationToken).ConfigureAwait(false); + CreateItem(item, cancellationToken); refresh = true; } @@ -2136,7 +2135,7 @@ namespace Emby.Server.Implementations.Library return item; } - public async Task GetNamedView(User user, + public UserView GetNamedView(User user, string name, string parentId, string viewType, @@ -2173,7 +2172,7 @@ namespace Emby.Server.Implementations.Library item.DisplayParentId = new Guid(parentId); } - await CreateItem(item, cancellationToken).ConfigureAwait(false); + CreateItem(item, cancellationToken); isNew = true; } @@ -2199,7 +2198,7 @@ namespace Emby.Server.Implementations.Library return item; } - public async Task GetShadowView(BaseItem parent, + public UserView GetShadowView(BaseItem parent, string viewType, string sortName, CancellationToken cancellationToken) @@ -2238,7 +2237,7 @@ namespace Emby.Server.Implementations.Library item.DisplayParentId = parentId; - await CreateItem(item, cancellationToken).ConfigureAwait(false); + CreateItem(item, cancellationToken); isNew = true; } @@ -2309,7 +2308,7 @@ namespace Emby.Server.Implementations.Library item.DisplayParentId = new Guid(parentId); } - await CreateItem(item, cancellationToken).ConfigureAwait(false); + CreateItem(item, cancellationToken); isNew = true; } @@ -2823,14 +2822,14 @@ namespace Emby.Server.Implementations.Library return ItemRepository.GetPeopleNames(query); } - public Task UpdatePeople(BaseItem item, List people) + public void UpdatePeople(BaseItem item, List people) { if (!item.SupportsPeople) { - return Task.FromResult(true); + return; } - return ItemRepository.UpdatePeople(item.Id, people); + ItemRepository.UpdatePeople(item.Id, people); } public async Task ConvertImageToLocal(IHasMetadata item, ItemImageInfo image, int imageIndex) diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index 1f2bf97a3..7ef5ca35e 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Library /// The repository. public IUserDataRepository Repository { get; set; } - public async Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken) + public void SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken) { if (userData == null) { @@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.Library foreach (var key in keys) { - await Repository.SaveUserData(userId, key, userData, cancellationToken).ConfigureAwait(false); + Repository.SaveUserData(userId, key, userData, cancellationToken); } var cacheKey = GetCacheKey(userId, item.Id); @@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.Library /// /// /// - public async Task SaveAllUserData(Guid userId, IEnumerable userData, CancellationToken cancellationToken) + public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken) { if (userData == null) { @@ -99,7 +99,7 @@ namespace Emby.Server.Implementations.Library cancellationToken.ThrowIfCancellationRequested(); - await Repository.SaveAllUserData(userId, userData, cancellationToken).ConfigureAwait(false); + Repository.SaveAllUserData(userId, userData, cancellationToken); } /// @@ -107,7 +107,7 @@ namespace Emby.Server.Implementations.Library /// /// /// - public IEnumerable GetAllUserData(Guid userId) + public List GetAllUserData(Guid userId) { if (userId == Guid.Empty) { @@ -187,7 +187,7 @@ namespace Emby.Server.Implementations.Library var userData = GetUserData(user.Id, item); var dto = GetUserItemDataDto(userData); - item.FillUserDataDtoValues(dto, userData, null, user, new ItemFields[]{}); + item.FillUserDataDtoValues(dto, userData, null, user, new ItemFields[] { }); return dto; } diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 211c54cee..e5fe2969f 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -160,9 +160,9 @@ namespace Emby.Server.Implementations.Library return Users.FirstOrDefault(u => string.Equals(u.Name, name, StringComparison.OrdinalIgnoreCase)); } - public async Task Initialize() + public void Initialize() { - Users = await LoadUsers().ConfigureAwait(false); + Users = LoadUsers(); var users = Users.ToList(); @@ -174,7 +174,7 @@ namespace Emby.Server.Implementations.Library if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value == UserLinkType.LinkedUser) { user.Policy.IsAdministrator = true; - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); } } } @@ -294,12 +294,12 @@ namespace Emby.Server.Implementations.Library if (success) { user.LastActivityDate = user.LastLoginDate = DateTime.UtcNow; - await UpdateUser(user).ConfigureAwait(false); - await UpdateInvalidLoginAttemptCount(user, 0).ConfigureAwait(false); + UpdateUser(user); + UpdateInvalidLoginAttemptCount(user, 0); } else { - await UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1).ConfigureAwait(false); + UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1); } _logger.Info("Authentication request for {0} {1}.", user.Name, success ? "has succeeded" : "has been denied"); @@ -307,7 +307,7 @@ namespace Emby.Server.Implementations.Library return success ? user : null; } - private async Task UpdateInvalidLoginAttemptCount(User user, int newValue) + private void UpdateInvalidLoginAttemptCount(User user, int newValue) { if (user.Policy.InvalidLoginAttemptCount != newValue || newValue > 0) { @@ -327,7 +327,7 @@ namespace Emby.Server.Implementations.Library //fireLockout = true; } - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); if (fireLockout) { @@ -372,7 +372,7 @@ namespace Emby.Server.Implementations.Library /// Loads the users from the repository /// /// IEnumerable{User}. - private async Task> LoadUsers() + private List LoadUsers() { var users = UserRepository.RetrieveAllUsers().ToList(); @@ -385,14 +385,14 @@ namespace Emby.Server.Implementations.Library user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); users.Add(user); user.Policy.IsAdministrator = true; user.Policy.EnableContentDeletion = true; user.Policy.EnableRemoteControlOfOtherUsers = true; - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); } return users; @@ -539,7 +539,7 @@ namespace Emby.Server.Implementations.Library /// The user. /// user /// - public async Task UpdateUser(User user) + public void UpdateUser(User user) { if (user == null) { @@ -554,7 +554,7 @@ namespace Emby.Server.Implementations.Library user.DateModified = DateTime.UtcNow; user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); OnUserUpdated(user); } @@ -599,7 +599,7 @@ namespace Emby.Server.Implementations.Library user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs { Argument = user }, _logger); @@ -653,7 +653,7 @@ namespace Emby.Server.Implementations.Library { var configPath = GetConfigurationFilePath(user); - await UserRepository.DeleteUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.DeleteUser(user, CancellationToken.None); try { @@ -667,7 +667,7 @@ namespace Emby.Server.Implementations.Library DeleteUserPolicy(user); // Force this to be lazy loaded again - Users = await LoadUsers().ConfigureAwait(false); + Users = LoadUsers(); OnUserDeleted(user); } @@ -681,17 +681,17 @@ namespace Emby.Server.Implementations.Library /// Resets the password by clearing it. /// /// Task. - public Task ResetPassword(User user) + public void ResetPassword(User user) { - return ChangePassword(user, GetSha1String(string.Empty)); + ChangePassword(user, GetSha1String(string.Empty)); } - public Task ResetEasyPassword(User user) + public void ResetEasyPassword(User user) { - return ChangeEasyPassword(user, GetSha1String(string.Empty)); + ChangeEasyPassword(user, GetSha1String(string.Empty)); } - public async Task ChangePassword(User user, string newPasswordSha1) + public void ChangePassword(User user, string newPasswordSha1) { if (user == null) { @@ -709,12 +709,12 @@ namespace Emby.Server.Implementations.Library user.Password = newPasswordSha1; - await UpdateUser(user).ConfigureAwait(false); + UpdateUser(user); EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs(user), _logger); } - public async Task ChangeEasyPassword(User user, string newPasswordSha1) + public void ChangeEasyPassword(User user, string newPasswordSha1) { if (user == null) { @@ -727,7 +727,7 @@ namespace Emby.Server.Implementations.Library user.EasyPassword = newPasswordSha1; - await UpdateUser(user).ConfigureAwait(false); + UpdateUser(user); EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs(user), _logger); } @@ -842,7 +842,7 @@ namespace Emby.Server.Implementations.Library }; } - public async Task RedeemPasswordResetPin(string pin) + public PinRedeemResult RedeemPasswordResetPin(string pin) { DeletePinFile(); @@ -863,12 +863,12 @@ namespace Emby.Server.Implementations.Library foreach (var user in users) { - await ResetPassword(user).ConfigureAwait(false); + ResetPassword(user); if (user.Policy.IsDisabled) { user.Policy.IsDisabled = false; - await UpdateUserPolicy(user, user.Policy, true).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, true); } usersReset.Add(user.Name); } @@ -945,13 +945,13 @@ namespace Emby.Server.Implementations.Library } private readonly object _policySyncLock = new object(); - public Task UpdateUserPolicy(string userId, UserPolicy userPolicy) + public void UpdateUserPolicy(string userId, UserPolicy userPolicy) { var user = GetUserById(userId); - return UpdateUserPolicy(user, userPolicy, true); + UpdateUserPolicy(user, userPolicy, true); } - private async Task UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent) + private void UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent) { // The xml serializer will output differently if the type is not exact if (userPolicy.GetType() != typeof(UserPolicy)) @@ -970,7 +970,7 @@ namespace Emby.Server.Implementations.Library user.Policy = userPolicy; } - await UpdateConfiguration(user, user.Configuration, true).ConfigureAwait(false); + UpdateConfiguration(user, user.Configuration, true); } private void DeleteUserPolicy(User user) @@ -1032,13 +1032,13 @@ namespace Emby.Server.Implementations.Library } private readonly object _configSyncLock = new object(); - public Task UpdateConfiguration(string userId, UserConfiguration config) + public void UpdateConfiguration(string userId, UserConfiguration config) { var user = GetUserById(userId); - return UpdateConfiguration(user, config, true); + UpdateConfiguration(user, config, true); } - private async Task UpdateConfiguration(User user, UserConfiguration config, bool fireEvent) + private void UpdateConfiguration(User user, UserConfiguration config, bool fireEvent) { var path = GetConfigurationFilePath(user); diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index 25c3e10e8..b02c114bb 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.Library if (UserView.IsUserSpecific(folder)) { - list.Add(await _libraryManager.GetNamedView(user, folder.Name, folder.Id.ToString("N"), folderViewType, null, cancellationToken).ConfigureAwait(false)); + list.Add(_libraryManager.GetNamedView(user, folder.Name, folder.Id.ToString("N"), folderViewType, null, cancellationToken)); continue; } @@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.Library if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparer.OrdinalIgnoreCase)) { - list.Add(await GetUserView(folder, folderViewType, string.Empty, cancellationToken).ConfigureAwait(false)); + list.Add(GetUserView(folder, folderViewType, string.Empty, cancellationToken)); } else { @@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.Library if (parents.Count > 0) { - list.Add(await GetUserView(parents, viewType, string.Empty, user, query.PresetViews, cancellationToken).ConfigureAwait(false)); + list.Add(GetUserView(parents, viewType, string.Empty, user, query.PresetViews, cancellationToken)); } } @@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.Library }, cancellationToken).ConfigureAwait(false); var channels = channelResult.Items; - + if (_config.Configuration.EnableChannelView && channels.Length > 0) { list.Add(await _channelManager.GetInternalChannelFolder(cancellationToken).ConfigureAwait(false)); @@ -172,7 +172,7 @@ namespace Emby.Server.Implementations.Library return GetUserSubView(name, parentId, type, sortName, cancellationToken); } - private async Task GetUserView(List parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken) + private Folder GetUserView(List parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken) { if (parents.Count == 1 && parents.All(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase))) { @@ -181,14 +181,14 @@ namespace Emby.Server.Implementations.Library return (Folder)parents[0]; } - return await GetUserView((Folder)parents[0], viewType, string.Empty, cancellationToken).ConfigureAwait(false); + return GetUserView((Folder)parents[0], viewType, string.Empty, cancellationToken); } var name = _localizationManager.GetLocalizedString("ViewType" + viewType); - return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false); + return _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken); } - public Task GetUserView(Folder parent, string viewType, string sortName, CancellationToken cancellationToken) + public UserView GetUserView(Folder parent, string viewType, string sortName, CancellationToken cancellationToken) { return _libraryManager.GetShadowView(parent, viewType, sortName, cancellationToken); } diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index bf30546ab..ac98d1043 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -558,7 +558,7 @@ namespace Emby.Server.Implementations.LiveTv if (isNew) { - await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItem(item, cancellationToken); } else if (forceUpdate) { @@ -875,7 +875,7 @@ namespace Emby.Server.Implementations.LiveTv if (isNew) { - await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItem(item, cancellationToken); } else if (dataChanged || info.DateLastUpdated > recording.DateLastSaved || statusChanged) { @@ -1410,7 +1410,7 @@ namespace Emby.Server.Implementations.LiveTv if (newPrograms.Count > 0) { - await _libraryManager.CreateItems(newPrograms, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItems(newPrograms, cancellationToken); } // TODO: Do this in bulk diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index d8bf363f2..9a9e619a6 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -179,7 +179,7 @@ namespace Emby.Server.Implementations.MediaEncoder if (saveChapters && changesMade) { - await _chapterManager.SaveChapters(video.Id.ToString(), chapters).ConfigureAwait(false); + _chapterManager.SaveChapters(video.Id.ToString(), chapters); } DeleteDeadImages(currentImages, chapters); diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 9b9596934..87832e7dd 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Playlists playlist.SetMediaType(options.MediaType); - await parentFolder.AddChild(playlist, CancellationToken.None).ConfigureAwait(false); + parentFolder.AddChild(playlist, CancellationToken.None); await playlist.RefreshMetadata(new MetadataRefreshOptions(_fileSystem) { ForceSave = true }, CancellationToken.None) .ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index d512ff4fb..f5b847ccf 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -4,7 +4,6 @@ using System.Globalization; using System.IO; using System.Linq; using System.Threading; -using System.Threading.Tasks; using Emby.Server.Implementations.Data; using MediaBrowser.Controller; using MediaBrowser.Controller.Security; @@ -51,14 +50,14 @@ namespace Emby.Server.Implementations.Security } } - public Task Create(AuthenticationInfo info, CancellationToken cancellationToken) + public void Create(AuthenticationInfo info, CancellationToken cancellationToken) { info.Id = Guid.NewGuid().ToString("N"); - return Update(info, cancellationToken); + Update(info, cancellationToken); } - public async Task Update(AuthenticationInfo info, CancellationToken cancellationToken) + public void Update(AuthenticationInfo info, CancellationToken cancellationToken) { if (info == null) { diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index ee373139f..0692a0ba5 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -6,11 +6,8 @@ using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.LiveTv; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Devices; @@ -253,7 +250,7 @@ namespace Emby.Server.Implementations.Session { try { - await _userManager.UpdateUser(user).ConfigureAwait(false); + _userManager.UpdateUser(user); } catch (Exception ex) { @@ -622,7 +619,7 @@ namespace Emby.Server.Implementations.Session { foreach (var user in users) { - await OnPlaybackStart(user.Id, libraryItem).ConfigureAwait(false); + OnPlaybackStart(user.Id, libraryItem); } } @@ -650,8 +647,7 @@ namespace Emby.Server.Implementations.Session /// /// The user identifier. /// The item. - /// Task. - private async Task OnPlaybackStart(Guid userId, IHasUserData item) + private void OnPlaybackStart(Guid userId, IHasUserData item) { var data = _userDataManager.GetUserData(userId, item); @@ -670,7 +666,7 @@ namespace Emby.Server.Implementations.Session data.Played = false; } - await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false); + _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None); } public Task OnPlaybackProgress(PlaybackProgressInfo info) @@ -702,7 +698,7 @@ namespace Emby.Server.Implementations.Session { foreach (var user in users) { - await OnPlaybackProgress(user, libraryItem, info).ConfigureAwait(false); + OnPlaybackProgress(user, libraryItem, info); } } @@ -730,7 +726,7 @@ namespace Emby.Server.Implementations.Session StartIdleCheckTimer(); } - private async Task OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info) + private void OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info) { var data = _userDataManager.GetUserData(user.Id, item); @@ -742,7 +738,7 @@ namespace Emby.Server.Implementations.Session UpdatePlaybackSettings(user, info, data); - await _userDataManager.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false); + _userDataManager.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None); } } @@ -842,7 +838,7 @@ namespace Emby.Server.Implementations.Session { foreach (var user in users) { - playedToCompletion = await OnPlaybackStopped(user.Id, libraryItem, info.PositionTicks, info.Failed).ConfigureAwait(false); + playedToCompletion = OnPlaybackStopped(user.Id, libraryItem, info.PositionTicks, info.Failed); } } @@ -875,7 +871,7 @@ namespace Emby.Server.Implementations.Session await SendPlaybackStoppedNotification(session, CancellationToken.None).ConfigureAwait(false); } - private async Task OnPlaybackStopped(Guid userId, BaseItem item, long? positionTicks, bool playbackFailed) + private bool OnPlaybackStopped(Guid userId, BaseItem item, long? positionTicks, bool playbackFailed) { bool playedToCompletion = false; @@ -896,7 +892,7 @@ namespace Emby.Server.Implementations.Session playedToCompletion = true; } - await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false); + _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None); } return playedToCompletion; @@ -1432,7 +1428,7 @@ namespace Emby.Server.Implementations.Session user = result; } - var token = await GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName).ConfigureAwait(false); + var token = GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName); EventHelper.FireEventIfNotNull(AuthenticationSucceeded, this, new GenericEventArgs(request), _logger); @@ -1454,7 +1450,7 @@ namespace Emby.Server.Implementations.Session } - private async Task GetAuthorizationToken(string userId, string deviceId, string app, string appVersion, string deviceName) + private string GetAuthorizationToken(string userId, string deviceId, string app, string appVersion, string deviceName) { var existing = _authRepo.Get(new AuthenticationInfoQuery { @@ -1484,12 +1480,12 @@ namespace Emby.Server.Implementations.Session }; _logger.Info("Creating new access token for user {0}", userId); - await _authRepo.Create(newToken, CancellationToken.None).ConfigureAwait(false); + _authRepo.Create(newToken, CancellationToken.None); return newToken.AccessToken; } - public async Task Logout(string accessToken) + public void Logout(string accessToken) { if (string.IsNullOrWhiteSpace(accessToken)) { @@ -1509,7 +1505,7 @@ namespace Emby.Server.Implementations.Session { existing.IsActive = false; - await _authRepo.Update(existing, CancellationToken.None).ConfigureAwait(false); + _authRepo.Update(existing, CancellationToken.None); var sessions = Sessions .Where(i => string.Equals(i.DeviceId, existing.DeviceId, StringComparison.OrdinalIgnoreCase)) @@ -1529,7 +1525,7 @@ namespace Emby.Server.Implementations.Session } } - public async Task RevokeUserTokens(string userId, string currentAccessToken) + public void RevokeUserTokens(string userId, string currentAccessToken) { var existing = _authRepo.Get(new AuthenticationInfoQuery { @@ -1541,14 +1537,14 @@ namespace Emby.Server.Implementations.Session { if (!string.Equals(currentAccessToken, info.AccessToken, StringComparison.OrdinalIgnoreCase)) { - await Logout(info.AccessToken).ConfigureAwait(false); + Logout(info.AccessToken); } } } - public Task RevokeToken(string token) + public void RevokeToken(string token) { - return Logout(token); + Logout(token); } /// diff --git a/Emby.Server.Implementations/Social/SharingManager.cs b/Emby.Server.Implementations/Social/SharingManager.cs index 54614c879..57cf93948 100644 --- a/Emby.Server.Implementations/Social/SharingManager.cs +++ b/Emby.Server.Implementations/Social/SharingManager.cs @@ -58,8 +58,8 @@ namespace Emby.Server.Implementations.Social }; AddShareInfo(info, externalUrl); - - await _repository.CreateShare(info).ConfigureAwait(false); + + _repository.CreateShare(info); return info; } @@ -92,9 +92,9 @@ namespace Emby.Server.Implementations.Social } } - public Task DeleteShare(string id) + public void DeleteShare(string id) { - return _repository.DeleteShare(id); + _repository.DeleteShare(id); } } } diff --git a/Emby.Server.Implementations/Social/SharingRepository.cs b/Emby.Server.Implementations/Social/SharingRepository.cs index a2a1f879a..f306e76c4 100644 --- a/Emby.Server.Implementations/Social/SharingRepository.cs +++ b/Emby.Server.Implementations/Social/SharingRepository.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Threading; -using System.Threading.Tasks; using Emby.Server.Implementations.Data; using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Logging; @@ -42,7 +40,7 @@ namespace Emby.Server.Implementations.Social } } - public async Task CreateShare(SocialShareInfo info) + public void CreateShare(SocialShareInfo info) { if (info == null) { @@ -109,7 +107,7 @@ namespace Emby.Server.Implementations.Social return info; } - public async Task DeleteShare(string id) + public void DeleteShare(string id) { } diff --git a/MediaBrowser.Api/DisplayPreferencesService.cs b/MediaBrowser.Api/DisplayPreferencesService.cs index 5a21fc9f4..4f8cc5255 100644 --- a/MediaBrowser.Api/DisplayPreferencesService.cs +++ b/MediaBrowser.Api/DisplayPreferencesService.cs @@ -88,9 +88,7 @@ namespace MediaBrowser.Api // Serialize to json and then back so that the core doesn't see the request dto type var displayPreferences = _jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(request)); - var task = _displayPreferencesManager.SaveDisplayPreferences(displayPreferences, request.UserId, request.Client, CancellationToken.None); - - Task.WaitAll(task); + _displayPreferencesManager.SaveDisplayPreferences(displayPreferences, request.UserId, request.Client, CancellationToken.None); } } } diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 47bd46ea5..9e83cf680 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -209,7 +209,7 @@ namespace MediaBrowser.Api // Do this first so that metadata savers can pull the updates from the database. if (request.People != null) { - await _libraryManager.UpdatePeople(item, request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList()); + _libraryManager.UpdatePeople(item, request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList()); } UpdateItem(request, item); diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 6c9f5d32b..44cc60b50 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -525,18 +525,18 @@ namespace MediaBrowser.Api.Library }); } - private async void LogDownload(BaseItem item, User user, AuthorizationInfo auth) + private void LogDownload(BaseItem item, User user, AuthorizationInfo auth) { try { - await _activityManager.Create(new ActivityLogEntry + _activityManager.Create(new ActivityLogEntry { Name = string.Format(_localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Name, item.Name), Type = "UserDownloadingContent", ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device), UserId = auth.UserId - }).ConfigureAwait(false); + }); } catch { @@ -915,7 +915,7 @@ namespace MediaBrowser.Api.Library : request.IncludeItemTypes.Split(','); var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; - + var query = new InternalItemsQuery(user) { IncludeItemTypes = includeTypes, diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index 18d261195..8f54b591e 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -313,14 +313,13 @@ namespace MediaBrowser.Api.Session public void Delete(RevokeKey request) { - var task = _sessionManager.RevokeToken(request.Key); + _sessionManager.RevokeToken(request.Key); - Task.WaitAll(task); } public void Post(CreateKey request) { - var task = _authRepo.Create(new AuthenticationInfo + _authRepo.Create(new AuthenticationInfo { AppName = request.App, IsActive = true, @@ -328,8 +327,6 @@ namespace MediaBrowser.Api.Session DateCreated = DateTime.UtcNow }, CancellationToken.None); - - Task.WaitAll(task); } public void Post(ReportSessionEnded request) diff --git a/MediaBrowser.Api/Social/SharingService.cs b/MediaBrowser.Api/Social/SharingService.cs index 37941bd4a..4f10667b7 100644 --- a/MediaBrowser.Api/Social/SharingService.cs +++ b/MediaBrowser.Api/Social/SharingService.cs @@ -121,8 +121,7 @@ namespace MediaBrowser.Api.Social public void Delete(DeleteShare request) { - var task = _sharingManager.DeleteShare(request.Id); - Task.WaitAll(task); + _sharingManager.DeleteShare(request.Id); } public async Task Get(GetShareImage request) @@ -157,7 +156,7 @@ namespace MediaBrowser.Api.Social } catch { - + } } diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 7d612a796..7a75aeb4b 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -125,7 +125,7 @@ namespace MediaBrowser.Api var user = _userManager.Users.First(); user.Name = request.Name; - await _userManager.UpdateUser(user).ConfigureAwait(false); + _userManager.UpdateUser(user); var result = new UpdateStartupUserResult(); diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 87a06e4d5..1bbc740c0 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -12,11 +12,9 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Entities.Audio; -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Services; -using MediaBrowser.Model.Extensions; namespace MediaBrowser.Api.UserLibrary { @@ -507,9 +505,9 @@ namespace MediaBrowser.Api.UserLibrary /// Posts the specified request. /// /// The request. - public async Task Post(MarkFavoriteItem request) + public object Post(MarkFavoriteItem request) { - var dto = await MarkFavorite(request.UserId, request.Id, true).ConfigureAwait(false); + var dto = MarkFavorite(request.UserId, request.Id, true); return ToOptimizedResult(dto); } @@ -520,7 +518,7 @@ namespace MediaBrowser.Api.UserLibrary /// The request. public object Delete(UnmarkFavoriteItem request) { - var dto = MarkFavorite(request.UserId, request.Id, false).Result; + var dto = MarkFavorite(request.UserId, request.Id, false); return ToOptimizedResult(dto); } @@ -531,8 +529,7 @@ namespace MediaBrowser.Api.UserLibrary /// The user id. /// The item id. /// if set to true [is favorite]. - /// Task{UserItemDataDto}. - private async Task MarkFavorite(string userId, string itemId, bool isFavorite) + private UserItemDataDto MarkFavorite(string userId, string itemId, bool isFavorite) { var user = _userManager.GetUserById(userId); @@ -544,7 +541,7 @@ namespace MediaBrowser.Api.UserLibrary // Set favorite status data.IsFavorite = isFavorite; - await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None).ConfigureAwait(false); + _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None); return _userDataRepository.GetUserDataDto(item, user); } @@ -555,7 +552,7 @@ namespace MediaBrowser.Api.UserLibrary /// The request. public object Delete(DeleteUserItemRating request) { - var dto = UpdateUserItemRating(request.UserId, request.Id, null).Result; + var dto = UpdateUserItemRating(request.UserId, request.Id, null); return ToOptimizedResult(dto); } @@ -564,9 +561,9 @@ namespace MediaBrowser.Api.UserLibrary /// Posts the specified request. /// /// The request. - public async Task Post(UpdateUserItemRating request) + public object Post(UpdateUserItemRating request) { - var dto = await UpdateUserItemRating(request.UserId, request.Id, request.Likes).ConfigureAwait(false); + var dto = UpdateUserItemRating(request.UserId, request.Id, request.Likes); return ToOptimizedResult(dto); } @@ -577,8 +574,7 @@ namespace MediaBrowser.Api.UserLibrary /// The user id. /// The item id. /// if set to true [likes]. - /// Task{UserItemDataDto}. - private async Task UpdateUserItemRating(string userId, string itemId, bool? likes) + private UserItemDataDto UpdateUserItemRating(string userId, string itemId, bool? likes) { var user = _userManager.GetUserById(userId); @@ -589,7 +585,7 @@ namespace MediaBrowser.Api.UserLibrary data.Likes = likes; - await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None).ConfigureAwait(false); + _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None); return _userDataRepository.GetUserDataDto(item, user); } diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index acdbf96f4..512356b43 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -387,7 +387,7 @@ namespace MediaBrowser.Api throw new ResourceNotFoundException("User not found"); } - await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), null).ConfigureAwait(false); + _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), null); await _userManager.DeleteUser(user).ConfigureAwait(false); } @@ -455,7 +455,7 @@ namespace MediaBrowser.Api if (request.ResetPassword) { - await _userManager.ResetPassword(user).ConfigureAwait(false); + _userManager.ResetPassword(user); } else { @@ -466,24 +466,18 @@ namespace MediaBrowser.Api throw new ArgumentException("Invalid user or password entered."); } - await _userManager.ChangePassword(user, request.NewPassword).ConfigureAwait(false); + _userManager.ChangePassword(user, request.NewPassword); var currentToken = _authContext.GetAuthorizationInfo(Request).Token; - await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken).ConfigureAwait(false); + _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken); } } public void Post(UpdateUserEasyPassword request) - { - var task = PostAsync(request); - Task.WaitAll(task); - } - - public async Task PostAsync(UpdateUserEasyPassword request) { AssertCanUpdateUser(_authContext, _userManager, request.Id, true); - + var user = _userManager.GetUserById(request.Id); if (user == null) @@ -493,11 +487,11 @@ namespace MediaBrowser.Api if (request.ResetPassword) { - await _userManager.ResetEasyPassword(user).ConfigureAwait(false); + _userManager.ResetEasyPassword(user); } else { - await _userManager.ChangeEasyPassword(user, request.NewPassword).ConfigureAwait(false); + _userManager.ChangeEasyPassword(user, request.NewPassword); } } @@ -506,13 +500,6 @@ namespace MediaBrowser.Api /// /// The request. public void Post(UpdateUser request) - { - var task = PostAsync(request); - - Task.WaitAll(task); - } - - public async Task PostAsync(UpdateUser request) { // We need to parse this manually because we told service stack not to with IRequiresRequestStream // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs @@ -524,13 +511,18 @@ namespace MediaBrowser.Api var user = _userManager.GetUserById(id); - var task = string.Equals(user.Name, dtoUser.Name, StringComparison.Ordinal) ? - _userManager.UpdateUser(user) : - _userManager.RenameUser(user, dtoUser.Name); + if (string.Equals(user.Name, dtoUser.Name, StringComparison.Ordinal)) + { + _userManager.UpdateUser(user); + } + else + { + var task = _userManager.RenameUser(user, dtoUser.Name); - await task.ConfigureAwait(false); + Task.WaitAll(task); + } - await _userManager.UpdateConfiguration(dtoUser.Id, dtoUser.Configuration); + _userManager.UpdateConfiguration(dtoUser.Id, dtoUser.Configuration); } /// @@ -570,21 +562,14 @@ namespace MediaBrowser.Api { AssertCanUpdateUser(_authContext, _userManager, request.Id, false); - var task = _userManager.UpdateConfiguration(request.Id, request); + _userManager.UpdateConfiguration(request.Id, request); - Task.WaitAll(task); } public void Post(UpdateUserPolicy request) - { - var task = UpdateUserPolicy(request); - Task.WaitAll(task); - } - - private async Task UpdateUserPolicy(UpdateUserPolicy request) { var user = _userManager.GetUserById(request.Id); - + // If removing admin access if (!request.IsAdministrator && user.Policy.IsAdministrator) { @@ -609,10 +594,10 @@ namespace MediaBrowser.Api } var currentToken = _authContext.GetAuthorizationInfo(Request).Token; - await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken).ConfigureAwait(false); + _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken); } - await _userManager.UpdateUserPolicy(request.Id, request).ConfigureAwait(false); + _userManager.UpdateUserPolicy(request.Id, request); } } } diff --git a/MediaBrowser.Controller/Chapters/IChapterManager.cs b/MediaBrowser.Controller/Chapters/IChapterManager.cs index 85feec40b..d1c190ab5 100644 --- a/MediaBrowser.Controller/Chapters/IChapterManager.cs +++ b/MediaBrowser.Controller/Chapters/IChapterManager.cs @@ -14,11 +14,11 @@ namespace MediaBrowser.Controller.Chapters /// /// The item identifier. /// List{ChapterInfo}. - IEnumerable GetChapters(string itemId); + List GetChapters(string itemId); /// /// Saves the chapters. /// - Task SaveChapters(string itemId, List chapters); + void SaveChapters(string itemId, List chapters); } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 51dc59c19..513b85d8b 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1771,7 +1771,7 @@ namespace MediaBrowser.Controller.Entities /// if set to true [reset position]. /// Task. /// - public virtual async Task MarkPlayed(User user, + public virtual void MarkPlayed(User user, DateTime? datePlayed, bool resetPosition) { @@ -1799,7 +1799,7 @@ namespace MediaBrowser.Controller.Entities data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow; data.Played = true; - await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false); + UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None); } /// @@ -1808,7 +1808,7 @@ namespace MediaBrowser.Controller.Entities /// The user. /// Task. /// - public virtual async Task MarkUnplayed(User user) + public virtual void MarkUnplayed(User user) { if (user == null) { @@ -1825,7 +1825,7 @@ namespace MediaBrowser.Controller.Entities data.LastPlayedDate = null; data.Played = false; - await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false); + UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None); } /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 11c0a5747..8a87f3c6a 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -186,7 +186,7 @@ namespace MediaBrowser.Controller.Entities /// The cancellation token. /// Task. /// Unable to add + item.Name - public async Task AddChild(BaseItem item, CancellationToken cancellationToken) + public void AddChild(BaseItem item, CancellationToken cancellationToken) { item.SetParent(this); @@ -209,7 +209,7 @@ namespace MediaBrowser.Controller.Entities item.DateModified = DateTime.UtcNow; } - await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + LibraryManager.CreateItem(item, cancellationToken); } /// @@ -469,7 +469,7 @@ namespace MediaBrowser.Controller.Entities } } - await LibraryManager.CreateItems(newItems, cancellationToken).ConfigureAwait(false); + LibraryManager.CreateItems(newItems, cancellationToken); } } else @@ -1370,7 +1370,7 @@ namespace MediaBrowser.Controller.Entities /// The date played. /// if set to true [reset position]. /// Task. - public override async Task MarkPlayed(User user, + public override void MarkPlayed(User user, DateTime? datePlayed, bool resetPosition) { @@ -1390,9 +1390,10 @@ namespace MediaBrowser.Controller.Entities var itemsResult = GetItemList(query); // Sweep through recursively and update status - var tasks = itemsResult.Select(c => c.MarkPlayed(user, datePlayed, resetPosition)); - - await Task.WhenAll(tasks).ConfigureAwait(false); + foreach (var item in itemsResult) + { + item.MarkPlayed(user, datePlayed, resetPosition); + } } /// @@ -1400,7 +1401,7 @@ namespace MediaBrowser.Controller.Entities /// /// The user. /// Task. - public override async Task MarkUnplayed(User user) + public override void MarkUnplayed(User user) { var itemsResult = GetItemList(new InternalItemsQuery { @@ -1412,9 +1413,10 @@ namespace MediaBrowser.Controller.Entities }); // Sweep through recursively and update status - var tasks = itemsResult.Select(c => c.MarkUnplayed(user)); - - await Task.WhenAll(tasks).ConfigureAwait(false); + foreach (var item in itemsResult) + { + item.MarkUnplayed(user); + } } public override bool IsPlayed(User user) diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 851686ea8..3c89037cc 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -165,7 +165,7 @@ namespace MediaBrowser.Controller.Entities } } } - + return _policy; } set { _policy = value; } @@ -194,24 +194,24 @@ namespace MediaBrowser.Controller.Entities var oldConfigurationDirectory = ConfigurationDirectoryPath; // Exceptions will be thrown if these paths already exist - if (FileSystem.DirectoryExists(newConfigDirectory)) + if (FileSystem.DirectoryExists(newConfigDirectory)) { FileSystem.DeleteDirectory(newConfigDirectory, true); } - if (FileSystem.DirectoryExists(oldConfigurationDirectory)) + if (FileSystem.DirectoryExists(oldConfigurationDirectory)) { - FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory); + FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory); } else { - FileSystem.CreateDirectory(newConfigDirectory); + FileSystem.CreateDirectory(newConfigDirectory); } } Name = newName; - return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)) + return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)) { ReplaceAllMetadata = true, ImageRefreshMode = ImageRefreshMode.FullRefresh, @@ -223,7 +223,8 @@ namespace MediaBrowser.Controller.Entities public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken) { - return UserManager.UpdateUser(this); + UserManager.UpdateUser(this); + return Task.FromResult(true); } /// diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index cd1781220..265d4d786 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -195,16 +195,14 @@ namespace MediaBrowser.Controller.Library /// /// The item. /// The cancellation token. - /// Task. - Task CreateItem(BaseItem item, CancellationToken cancellationToken); + void CreateItem(BaseItem item, CancellationToken cancellationToken); /// /// Creates the items. /// /// The items. /// The cancellation token. - /// Task. - Task CreateItems(IEnumerable items, CancellationToken cancellationToken); + void CreateItems(IEnumerable items, CancellationToken cancellationToken); /// /// Updates the item. @@ -303,7 +301,7 @@ namespace MediaBrowser.Controller.Library /// Name of the sort. /// The cancellation token. /// Task<UserView>. - Task GetNamedView(User user, + UserView GetNamedView(User user, string name, string parentId, string viewType, @@ -319,7 +317,7 @@ namespace MediaBrowser.Controller.Library /// Name of the sort. /// The cancellation token. /// Task<UserView>. - Task GetNamedView(User user, + UserView GetNamedView(User user, string name, string viewType, string sortName, @@ -363,7 +361,7 @@ namespace MediaBrowser.Controller.Library /// Name of the sort. /// The cancellation token. /// Task<UserView>. - Task GetShadowView(BaseItem parent, + UserView GetShadowView(BaseItem parent, string viewType, string sortName, CancellationToken cancellationToken); @@ -471,8 +469,7 @@ namespace MediaBrowser.Controller.Library /// /// The item. /// The people. - /// Task. - Task UpdatePeople(BaseItem item, List people); + void UpdatePeople(BaseItem item, List people); /// /// Gets the item ids. diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs index b364ab990..cd4bd2e34 100644 --- a/MediaBrowser.Controller/Library/IUserDataManager.cs +++ b/MediaBrowser.Controller/Library/IUserDataManager.cs @@ -4,7 +4,6 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using System; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Library @@ -28,7 +27,7 @@ namespace MediaBrowser.Controller.Library /// The reason. /// The cancellation token. /// Task. - Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); + void SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); UserItemData GetUserData(IHasUserData user, IHasUserData item); @@ -47,7 +46,7 @@ namespace MediaBrowser.Controller.Library /// /// /// - IEnumerable GetAllUserData(Guid userId); + List GetAllUserData(Guid userId); /// /// Save the all provided user data for the given user @@ -56,7 +55,7 @@ namespace MediaBrowser.Controller.Library /// /// /// - Task SaveAllUserData(Guid userId, IEnumerable userData, CancellationToken cancellationToken); + void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken); /// /// Updates playstate for an item and returns true or false indicating if it was played to completion diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index ef68d2560..6da3e53aa 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -91,7 +91,7 @@ namespace MediaBrowser.Controller.Library /// The user. /// user /// - Task UpdateUser(User user); + void UpdateUser(User user); /// /// Creates the user. @@ -116,7 +116,7 @@ namespace MediaBrowser.Controller.Library /// /// The user. /// Task. - Task ResetPassword(User user); + void ResetPassword(User user); /// /// Gets the offline user dto. @@ -130,7 +130,7 @@ namespace MediaBrowser.Controller.Library /// /// The user. /// Task. - Task ResetEasyPassword(User user); + void ResetEasyPassword(User user); /// /// Changes the password. @@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Library /// The user. /// The new password sha1. /// Task. - Task ChangePassword(User user, string newPasswordSha1); + void ChangePassword(User user, string newPasswordSha1); /// /// Changes the easy password. @@ -146,7 +146,7 @@ namespace MediaBrowser.Controller.Library /// The user. /// The new password sha1. /// Task. - Task ChangeEasyPassword(User user, string newPasswordSha1); + void ChangeEasyPassword(User user, string newPasswordSha1); /// /// Gets the user dto. @@ -179,7 +179,7 @@ namespace MediaBrowser.Controller.Library /// /// The pin. /// true if XXXX, false otherwise. - Task RedeemPasswordResetPin(string pin); + PinRedeemResult RedeemPasswordResetPin(string pin); /// /// Gets the user policy. @@ -201,14 +201,14 @@ namespace MediaBrowser.Controller.Library /// The user identifier. /// The new configuration. /// Task. - Task UpdateConfiguration(string userId, UserConfiguration newConfiguration); + void UpdateConfiguration(string userId, UserConfiguration newConfiguration); /// /// Updates the user policy. /// /// The user identifier. /// The user policy. - Task UpdateUserPolicy(string userId, UserPolicy userPolicy); + void UpdateUserPolicy(string userId, UserPolicy userPolicy); /// /// Makes the valid username. diff --git a/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs b/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs index abf96994f..25aba6bd9 100644 --- a/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs +++ b/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Entities; using System; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -19,9 +18,9 @@ namespace MediaBrowser.Controller.Persistence /// The client. /// The cancellation token. /// Task. - Task SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, + void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken); - + /// /// Saves all display preferences for a user /// @@ -29,7 +28,7 @@ namespace MediaBrowser.Controller.Persistence /// The user id. /// The cancellation token. /// Task. - Task SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, + void SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, CancellationToken cancellationToken); /// /// Gets the display preferences. diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index bf54914b1..3d05d2fca 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -3,7 +3,6 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; @@ -19,16 +18,14 @@ namespace MediaBrowser.Controller.Persistence /// /// The item. /// The cancellation token. - /// Task. - Task SaveItem(BaseItem item, CancellationToken cancellationToken); + void SaveItem(BaseItem item, CancellationToken cancellationToken); /// /// Deletes the item. /// /// The identifier. /// The cancellation token. - /// Task. - Task DeleteItem(Guid id, CancellationToken cancellationToken); + void DeleteItem(Guid id, CancellationToken cancellationToken); /// /// Gets the critic reviews. @@ -42,16 +39,14 @@ namespace MediaBrowser.Controller.Persistence /// /// The item id. /// The critic reviews. - /// Task. - Task SaveCriticReviews(Guid itemId, IEnumerable criticReviews); + void SaveCriticReviews(Guid itemId, IEnumerable criticReviews); /// /// Saves the items. /// /// The items. /// The cancellation token. - /// Task. - Task SaveItems(List items, CancellationToken cancellationToken); + void SaveItems(List items, CancellationToken cancellationToken); /// /// Retrieves the item. @@ -78,7 +73,7 @@ namespace MediaBrowser.Controller.Persistence /// /// Saves the chapters. /// - Task SaveChapters(Guid id, List chapters); + void SaveChapters(Guid id, List chapters); /// /// Gets the media streams. @@ -93,8 +88,7 @@ namespace MediaBrowser.Controller.Persistence /// The identifier. /// The streams. /// The cancellation token. - /// Task. - Task SaveMediaStreams(Guid id, List streams, CancellationToken cancellationToken); + void SaveMediaStreams(Guid id, List streams, CancellationToken cancellationToken); /// /// Gets the item ids. @@ -128,8 +122,7 @@ namespace MediaBrowser.Controller.Persistence /// /// The item identifier. /// The people. - /// Task. - Task UpdatePeople(Guid itemId, List people); + void UpdatePeople(Guid itemId, List people); /// /// Gets the people names. @@ -156,8 +149,7 @@ namespace MediaBrowser.Controller.Persistence /// Updates the inherited values. /// /// The cancellation token. - /// Task. - Task UpdateInheritedValues(CancellationToken cancellationToken); + void UpdateInheritedValues(CancellationToken cancellationToken); int GetCount(InternalItemsQuery query); diff --git a/MediaBrowser.Controller/Persistence/IUserDataRepository.cs b/MediaBrowser.Controller/Persistence/IUserDataRepository.cs index ca4dc9751..f79a3a9fc 100644 --- a/MediaBrowser.Controller/Persistence/IUserDataRepository.cs +++ b/MediaBrowser.Controller/Persistence/IUserDataRepository.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Entities; using System; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -19,7 +18,7 @@ namespace MediaBrowser.Controller.Persistence /// The user data. /// The cancellation token. /// Task. - Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken); + void SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken); /// /// Gets the user data. @@ -36,7 +35,7 @@ namespace MediaBrowser.Controller.Persistence /// /// /// - IEnumerable GetAllUserData(Guid userId); + List GetAllUserData(Guid userId); /// /// Save all user data associated with the given user @@ -45,7 +44,7 @@ namespace MediaBrowser.Controller.Persistence /// /// /// - Task SaveAllUserData(Guid userId, IEnumerable userData, CancellationToken cancellationToken); + void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/Persistence/IUserRepository.cs b/MediaBrowser.Controller/Persistence/IUserRepository.cs index 80961a369..721ddb7e3 100644 --- a/MediaBrowser.Controller/Persistence/IUserRepository.cs +++ b/MediaBrowser.Controller/Persistence/IUserRepository.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using System.Collections.Generic; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -16,7 +15,7 @@ namespace MediaBrowser.Controller.Persistence /// The user. /// The cancellation token. /// Task. - Task DeleteUser(User user, CancellationToken cancellationToken); + void DeleteUser(User user, CancellationToken cancellationToken); /// /// Saves the user. @@ -24,7 +23,7 @@ namespace MediaBrowser.Controller.Persistence /// The user. /// The cancellation token. /// Task. - Task SaveUser(User user, CancellationToken cancellationToken); + void SaveUser(User user, CancellationToken cancellationToken); /// /// Retrieves all users. diff --git a/MediaBrowser.Controller/Security/IAuthenticationRepository.cs b/MediaBrowser.Controller/Security/IAuthenticationRepository.cs index 219b07028..f80ee6e7f 100644 --- a/MediaBrowser.Controller/Security/IAuthenticationRepository.cs +++ b/MediaBrowser.Controller/Security/IAuthenticationRepository.cs @@ -1,6 +1,5 @@ using MediaBrowser.Model.Querying; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Security { @@ -12,7 +11,7 @@ namespace MediaBrowser.Controller.Security /// The information. /// The cancellation token. /// Task. - Task Create(AuthenticationInfo info, CancellationToken cancellationToken); + void Create(AuthenticationInfo info, CancellationToken cancellationToken); /// /// Updates the specified information. @@ -20,7 +19,7 @@ namespace MediaBrowser.Controller.Security /// The information. /// The cancellation token. /// Task. - Task Update(AuthenticationInfo info, CancellationToken cancellationToken); + void Update(AuthenticationInfo info, CancellationToken cancellationToken); /// /// Gets the specified query. diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 8d77e0747..603e5ef76 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -318,19 +318,19 @@ namespace MediaBrowser.Controller.Session /// /// The access token. /// Task. - Task Logout(string accessToken); + void Logout(string accessToken); /// /// Revokes the user tokens. /// /// Task. - Task RevokeUserTokens(string userId, string currentAccessToken); + void RevokeUserTokens(string userId, string currentAccessToken); /// /// Revokes the token. /// /// The identifier. /// Task. - Task RevokeToken(string id); + void RevokeToken(string id); } } \ No newline at end of file diff --git a/MediaBrowser.Model/Activity/IActivityManager.cs b/MediaBrowser.Model/Activity/IActivityManager.cs index 7032dff14..396be9573 100644 --- a/MediaBrowser.Model/Activity/IActivityManager.cs +++ b/MediaBrowser.Model/Activity/IActivityManager.cs @@ -1,5 +1,4 @@ using System; -using System.Threading.Tasks; using MediaBrowser.Model.Events; using MediaBrowser.Model.Querying; @@ -9,7 +8,7 @@ namespace MediaBrowser.Model.Activity { event EventHandler> EntryCreated; - Task Create(ActivityLogEntry entry); + void Create(ActivityLogEntry entry); QueryResult GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit); } diff --git a/MediaBrowser.Model/Activity/IActivityRepository.cs b/MediaBrowser.Model/Activity/IActivityRepository.cs index c1952d436..8ee87ee2e 100644 --- a/MediaBrowser.Model/Activity/IActivityRepository.cs +++ b/MediaBrowser.Model/Activity/IActivityRepository.cs @@ -1,12 +1,11 @@ using System; -using System.Threading.Tasks; using MediaBrowser.Model.Querying; namespace MediaBrowser.Model.Activity { public interface IActivityRepository { - Task Create(ActivityLogEntry entry); + void Create(ActivityLogEntry entry); QueryResult GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit); } diff --git a/MediaBrowser.Model/Social/ISharingManager.cs b/MediaBrowser.Model/Social/ISharingManager.cs index 94c22baba..28c8c7db2 100644 --- a/MediaBrowser.Model/Social/ISharingManager.cs +++ b/MediaBrowser.Model/Social/ISharingManager.cs @@ -22,6 +22,6 @@ namespace MediaBrowser.Model.Social /// /// The identifier. /// Task. - Task DeleteShare(string id); + void DeleteShare(string id); } } diff --git a/MediaBrowser.Model/Social/ISharingRepository.cs b/MediaBrowser.Model/Social/ISharingRepository.cs index 1dadd7f71..dd88ddd04 100644 --- a/MediaBrowser.Model/Social/ISharingRepository.cs +++ b/MediaBrowser.Model/Social/ISharingRepository.cs @@ -1,11 +1,10 @@ -using System.Threading.Tasks; - + namespace MediaBrowser.Model.Social { public interface ISharingRepository { - Task CreateShare(SocialShareInfo info); - Task DeleteShare(string id); + void CreateShare(SocialShareInfo info); + void DeleteShare(string id); SocialShareInfo GetShareInfo(string id); } } diff --git a/MediaBrowser.Providers/Chapters/ChapterManager.cs b/MediaBrowser.Providers/Chapters/ChapterManager.cs index d3e9efd82..1bbc6fa4e 100644 --- a/MediaBrowser.Providers/Chapters/ChapterManager.cs +++ b/MediaBrowser.Providers/Chapters/ChapterManager.cs @@ -33,14 +33,14 @@ namespace MediaBrowser.Providers.Chapters _itemRepo = itemRepo; } - public IEnumerable GetChapters(string itemId) + public List GetChapters(string itemId) { return _itemRepo.GetChapters(new Guid(itemId)); } - public Task SaveChapters(string itemId, List chapters) + public void SaveChapters(string itemId, List chapters) { - return _itemRepo.SaveChapters(new Guid(itemId), chapters); + _itemRepo.SaveChapters(new Guid(itemId), chapters); } } } diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 5d531c95c..9a7ced0a5 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -201,7 +201,7 @@ namespace MediaBrowser.Providers.Manager { var baseItem = result.Item as BaseItem; - await LibraryManager.UpdatePeople(baseItem, result.People); + LibraryManager.UpdatePeople(baseItem, result.People); await SavePeopleMetadata(result.People, libraryOptions, cancellationToken).ConfigureAwait(false); } await result.Item.UpdateToRepository(reason, cancellationToken).ConfigureAwait(false); @@ -519,7 +519,7 @@ namespace MediaBrowser.Providers.Manager userDataList.AddRange(localItem.UserDataList); } - MergeData(localItem, temp, new MetadataFields[]{}, !options.ReplaceAllMetadata, true); + MergeData(localItem, temp, new MetadataFields[] { }, !options.ReplaceAllMetadata, true); refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport; // Only one local provider allowed per item @@ -567,7 +567,7 @@ namespace MediaBrowser.Providers.Manager else { // TODO: If the new metadata from above has some blank data, this can cause old data to get filled into those empty fields - MergeData(metadata, temp, new MetadataFields[]{}, false, false); + MergeData(metadata, temp, new MetadataFields[] { }, false, false); MergeData(temp, metadata, item.LockedFields, true, false); } } @@ -580,7 +580,7 @@ namespace MediaBrowser.Providers.Manager await RunCustomProvider(provider, item, logName, options, refreshResult, cancellationToken).ConfigureAwait(false); } - await ImportUserData(item, userDataList, cancellationToken).ConfigureAwait(false); + ImportUserData(item, userDataList, cancellationToken); return refreshResult; } @@ -595,7 +595,7 @@ namespace MediaBrowser.Providers.Manager return true; } - private async Task ImportUserData(TItemType item, List userDataList, CancellationToken cancellationToken) + private void ImportUserData(TItemType item, List userDataList, CancellationToken cancellationToken) { var hasUserData = item as IHasUserData; @@ -603,8 +603,7 @@ namespace MediaBrowser.Providers.Manager { foreach (var userData in userDataList) { - await UserDataManager.SaveUserData(userData.UserId, hasUserData, userData, UserDataSaveReason.Import, cancellationToken) - .ConfigureAwait(false); + UserDataManager.SaveUserData(userData.UserId, hasUserData, userData, UserDataSaveReason.Import, cancellationToken); } } } @@ -704,7 +703,7 @@ namespace MediaBrowser.Providers.Manager foreach (var result in results) { - MergeData(result, temp, new MetadataFields[]{}, false, false); + MergeData(result, temp, new MetadataFields[] { }, false, false); } return refreshResult; diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs index b0785298b..aa6e5ad31 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Providers.MediaInfo cancellationToken.ThrowIfCancellationRequested(); - await Fetch(item, cancellationToken, result).ConfigureAwait(false); + Fetch(item, cancellationToken, result); return ItemUpdateType.MetadataImport; } @@ -92,7 +92,7 @@ namespace MediaBrowser.Providers.MediaInfo /// The cancellation token. /// The media information. /// Task. - protected async Task Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo) + protected void Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo) { var mediaStreams = mediaInfo.MediaStreams; @@ -102,12 +102,12 @@ namespace MediaBrowser.Providers.MediaInfo audio.RunTimeTicks = mediaInfo.RunTimeTicks; audio.Size = mediaInfo.Size; - var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.'); + //var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.'); //audio.Container = extension; - await FetchDataFromTags(audio, mediaInfo).ConfigureAwait(false); + FetchDataFromTags(audio, mediaInfo); - await _itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken).ConfigureAwait(false); + _itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken); } /// @@ -115,7 +115,7 @@ namespace MediaBrowser.Providers.MediaInfo /// /// The audio. /// The data. - private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data) + private void FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data) { // Only set Name if title was found in the dictionary if (!string.IsNullOrEmpty(data.Name)) @@ -137,7 +137,7 @@ namespace MediaBrowser.Providers.MediaInfo }); } - await _libraryManager.UpdatePeople(audio, people).ConfigureAwait(false); + _libraryManager.UpdatePeople(audio, people); } audio.Album = data.Album; diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 76cd02cef..64a485bc2 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -198,7 +198,7 @@ namespace MediaBrowser.Providers.MediaInfo var libraryOptions = _libraryManager.GetLibraryOptions(video); FetchEmbeddedInfo(video, mediaInfo, options, libraryOptions); - await FetchPeople(video, mediaInfo, options).ConfigureAwait(false); + FetchPeople(video, mediaInfo, options); video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1260); @@ -211,7 +211,7 @@ namespace MediaBrowser.Providers.MediaInfo video.Video3DFormat = video.Video3DFormat ?? mediaInfo.Video3DFormat; - await _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken).ConfigureAwait(false); + _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken); if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh || options.MetadataRefreshMode == MetadataRefreshMode.Default) @@ -231,7 +231,7 @@ namespace MediaBrowser.Providers.MediaInfo await _encodingManager.RefreshChapterImages(video, chapters, extractDuringScan, false, cancellationToken).ConfigureAwait(false); - await _chapterManager.SaveChapters(video.Id.ToString(), chapters).ConfigureAwait(false); + _chapterManager.SaveChapters(video.Id.ToString(), chapters); } } @@ -426,7 +426,7 @@ namespace MediaBrowser.Providers.MediaInfo } } - private async Task FetchPeople(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options) + private void FetchPeople(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options) { var isFullRefresh = options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh; @@ -446,7 +446,7 @@ namespace MediaBrowser.Providers.MediaInfo }); } - await _libraryManager.UpdatePeople(video, people); + _libraryManager.UpdatePeople(video, people); } } } @@ -560,7 +560,7 @@ namespace MediaBrowser.Providers.MediaInfo titleNumber = primaryTitle.VideoTitleSetNumber; item.RunTimeTicks = GetRuntime(primaryTitle); } - + return _mediaEncoder.GetPrimaryPlaylistVobFiles(item.Path, mount, titleNumber) .Select(Path.GetFileName) .ToArray(); diff --git a/MediaBrowser.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.cs index aef29abbe..791d14b60 100644 --- a/MediaBrowser.Providers/TV/DummySeasonProvider.cs +++ b/MediaBrowser.Providers/TV/DummySeasonProvider.cs @@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.TV public async Task Run(Series series, CancellationToken cancellationToken) { await RemoveObsoleteSeasons(series).ConfigureAwait(false); - + var hasNewSeasons = await AddDummySeasonFolders(series, cancellationToken).ConfigureAwait(false); if (hasNewSeasons) @@ -129,8 +129,8 @@ namespace MediaBrowser.Providers.TV }; season.SetParent(series); - - await series.AddChild(season, cancellationToken).ConfigureAwait(false); + + series.AddChild(season, cancellationToken); await season.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index cfe20c741..44e3cff6a 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -206,7 +206,7 @@ namespace MediaBrowser.Providers.TV { var existingEpisodes = (from s in series from c in s.GetRecursiveChildren(i => i is Episode).Cast() - select new Tuple((c.ParentIndexNumber ?? 0) , c)) + select new Tuple((c.ParentIndexNumber ?? 0), c)) .ToList(); var lookup = episodeLookup as IList> ?? episodeLookup.ToList(); @@ -466,7 +466,7 @@ namespace MediaBrowser.Providers.TV episode.SetParent(season); - await season.AddChild(episode, cancellationToken).ConfigureAwait(false); + season.AddChild(episode, cancellationToken); await episode.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken).ConfigureAwait(false); } @@ -534,7 +534,7 @@ namespace MediaBrowser.Providers.TV settings.CheckCharacters = false; settings.IgnoreProcessingInstructions = true; settings.IgnoreComments = true; - + // Use XmlReader for best performance using (var reader = XmlReader.Create(streamReader, settings)) { diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 3aa3d5403..87c8a70ae 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.744 + 3.0.747 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index ea30175e6..20c043007 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.744 + 3.0.747 Emby.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + -- cgit v1.2.3