From b748d0784a6b2443ba841190a8ca9b6f0ae62828 Mon Sep 17 00:00:00 2001 From: softworkz Date: Tue, 20 Dec 2016 22:40:07 +0100 Subject: [PATCH 01/48] Enhanced sync events --- .../Sync/SyncManager.cs | 27 +++++++++---------- .../Sync/SyncNotificationEntryPoint.cs | 12 +++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Emby.Server.Implementations/Sync/SyncManager.cs b/Emby.Server.Implementations/Sync/SyncManager.cs index 13f60f5ee..061129e5f 100644 --- a/Emby.Server.Implementations/Sync/SyncManager.cs +++ b/Emby.Server.Implementations/Sync/SyncManager.cs @@ -1042,10 +1042,7 @@ namespace Emby.Server.Implementations.Sync throw new ArgumentException("Operation is not valid for this job item"); } - if (jobItem.Status != SyncJobItemStatus.Synced) - { - jobItem.Status = SyncJobItemStatus.Cancelled; - } + jobItem.Status = SyncJobItemStatus.Cancelled; jobItem.Progress = 0; jobItem.IsMarkedForRemoval = true; @@ -1071,18 +1068,18 @@ namespace Emby.Server.Implementations.Sync _logger.ErrorException("Error deleting directory {0}", ex, path); } - //var jobItemsResult = GetJobItems(new SyncJobItemQuery - //{ - // AddMetadata = false, - // JobId = jobItem.JobId, - // Limit = 0, - // Statuses = new[] { SyncJobItemStatus.Converting, SyncJobItemStatus.Failed, SyncJobItemStatus.Queued, SyncJobItemStatus.ReadyToTransfer, SyncJobItemStatus.Synced, SyncJobItemStatus.Transferring } - //}); + var jobItemsResult = GetJobItems(new SyncJobItemQuery + { + AddMetadata = false, + JobId = jobItem.JobId, + Limit = 0, + Statuses = new[] { SyncJobItemStatus.Converting, SyncJobItemStatus.Queued, SyncJobItemStatus.ReadyToTransfer, SyncJobItemStatus.Synced, SyncJobItemStatus.Transferring } + }); - //if (jobItemsResult.TotalRecordCount == 0) - //{ - // await CancelJob(jobItem.JobId).ConfigureAwait(false); - //} + if (jobItemsResult.TotalRecordCount == 0) + { + await CancelJob(jobItem.JobId).ConfigureAwait(false); + } } public Task MarkJobItemForRemoval(string id) diff --git a/Emby.Server.Implementations/Sync/SyncNotificationEntryPoint.cs b/Emby.Server.Implementations/Sync/SyncNotificationEntryPoint.cs index 46cdb28a4..06e0e66a9 100644 --- a/Emby.Server.Implementations/Sync/SyncNotificationEntryPoint.cs +++ b/Emby.Server.Implementations/Sync/SyncNotificationEntryPoint.cs @@ -38,6 +38,18 @@ namespace Emby.Server.Implementations.Sync } } + + if (item.Status == SyncJobItemStatus.Cancelled) + { + try + { + await _sessionManager.SendMessageToUserDeviceSessions(item.TargetId, "SyncJobItemCancelled", item, CancellationToken.None).ConfigureAwait(false); + } + catch + { + + } + } } public void Dispose() From d26a5086c1a802e5f6e57506fbed918b81c07d97 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 21 Dec 2016 23:11:23 -0500 Subject: [PATCH 02/48] resolve tray icon not opening links on osx --- Emby.Server.Core/ApplicationHost.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Core/ApplicationHost.cs b/Emby.Server.Core/ApplicationHost.cs index a0a7416e7..8af2c9f91 100644 --- a/Emby.Server.Core/ApplicationHost.cs +++ b/Emby.Server.Core/ApplicationHost.cs @@ -1583,7 +1583,8 @@ namespace Emby.Server.Core public void LaunchUrl(string url) { - if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) + if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows && + EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.OSX) { throw new NotImplementedException(); } From 961ec0b815e0857abaaa0f474ae13dfa3b6b25ba Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 21 Dec 2016 23:28:00 -0500 Subject: [PATCH 03/48] update browser launcher --- Emby.Server.Core/ApplicationHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Core/ApplicationHost.cs b/Emby.Server.Core/ApplicationHost.cs index 8af2c9f91..3590ade40 100644 --- a/Emby.Server.Core/ApplicationHost.cs +++ b/Emby.Server.Core/ApplicationHost.cs @@ -1592,7 +1592,7 @@ namespace Emby.Server.Core var process = ProcessFactory.Create(new ProcessOptions { FileName = url, - EnableRaisingEvents = true, + //EnableRaisingEvents = true, UseShellExecute = true, ErrorDialog = false }); From a447fd291aef2088d890571e80e4d498fc4498d2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 21 Dec 2016 23:47:59 -0500 Subject: [PATCH 04/48] update osx detection --- .../EnvironmentInfo/EnvironmentInfo.cs | 6 ++++++ MediaBrowser.Server.Mac/Main.cs | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs index 6cc4626ea..dcc974413 100644 --- a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs +++ b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs @@ -10,11 +10,17 @@ namespace Emby.Common.Implementations.EnvironmentInfo public class EnvironmentInfo : IEnvironmentInfo { public MediaBrowser.Model.System.Architecture? CustomArchitecture { get; set; } + public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; } public MediaBrowser.Model.System.OperatingSystem OperatingSystem { get { + if (CustomOperatingSystem.HasValue) + { + return CustomOperatingSystem.Value; + } + #if NET46 switch (Environment.OSVersion.Platform) { diff --git a/MediaBrowser.Server.Mac/Main.cs b/MediaBrowser.Server.Mac/Main.cs index cda6f459a..6d02c7a1a 100644 --- a/MediaBrowser.Server.Mac/Main.cs +++ b/MediaBrowser.Server.Mac/Main.cs @@ -142,7 +142,10 @@ namespace MediaBrowser.Server.Mac private static EnvironmentInfo GetEnvironmentInfo() { - var info = new EnvironmentInfo(); + var info = new EnvironmentInfo() + { + CustomOperatingSystem = MediaBrowser.Model.System.OperatingSystem.OSX + }; var uname = GetUnixName(); From f167777c7b4872f0f3d2be588139c932ca252e4d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 04:45:02 -0500 Subject: [PATCH 05/48] update string compare --- SocketHttpListener.Portable/Net/HttpConnection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SocketHttpListener.Portable/Net/HttpConnection.cs b/SocketHttpListener.Portable/Net/HttpConnection.cs index bc4286dc8..3baffd258 100644 --- a/SocketHttpListener.Portable/Net/HttpConnection.cs +++ b/SocketHttpListener.Portable/Net/HttpConnection.cs @@ -209,7 +209,7 @@ namespace SocketHttpListener.Net // TODO: can we get this stream before reading the input? if (o_stream == null) { - context.Response.DetermineIfChunked(); + //context.Response.DetermineIfChunked(); if (context.Response.SendChunked || isExpect100Continue || context.Request.IsWebSocketRequest || true) { @@ -508,7 +508,7 @@ namespace SocketHttpListener.Net { force_close |= !context.Request.KeepAlive; if (!force_close) - force_close = (context.Response.Headers["connection"] == "close"); + force_close = (string.Equals(context.Response.Headers["connection"], "close", StringComparison.OrdinalIgnoreCase)); /* if (!force_close) { // bool conn_close = (status_code == 400 || status_code == 408 || status_code == 411 || From d9190bb7d8955aba65a08c3b5e95dc67f946a72a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 10:57:28 -0500 Subject: [PATCH 06/48] update components --- MediaBrowser.Server.Mono/MonoAppHost.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/MediaBrowser.Server.Mono/MonoAppHost.cs b/MediaBrowser.Server.Mono/MonoAppHost.cs index 8def1ca2b..932e2d6cd 100644 --- a/MediaBrowser.Server.Mono/MonoAppHost.cs +++ b/MediaBrowser.Server.Mono/MonoAppHost.cs @@ -51,8 +51,11 @@ namespace MediaBrowser.Server.Mono } else if (environment.OperatingSystem == Model.System.OperatingSystem.Linux) { + info.FFMpegFilename = "ffmpeg"; + info.FFProbeFilename = "ffprobe"; info.ArchiveType = "7z"; info.Version = "20160215"; + info.DownloadUrls = GetDownloadUrls(); } // No version available - user requirement @@ -61,6 +64,25 @@ namespace MediaBrowser.Server.Mono return info; } + private string[] GetDownloadUrls() + { + switch (EnvironmentInfo.SystemArchitecture) + { + case Architecture.X64: + return new[] + { + "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-64bit-static.7z" + }; + case Architecture.X86: + return new[] + { + "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-32bit-static.7z" + }; + } + + return new string[] { }; + } + protected override void RestartInternal() { MainClass.Restart(StartupOptions); From 11e33cd00c8a474201926b8755fdd6254375432b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 10:57:45 -0500 Subject: [PATCH 07/48] add scheduled task error handling --- .../ScheduledTasks/ScheduledTaskWorker.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index cbc7c7c2d..de528a94f 100644 --- a/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -282,9 +282,12 @@ namespace Emby.Common.Implementations.ScheduledTasks throw new ArgumentNullException("value"); } - SaveTriggers(value); + // This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly + var triggerList = value.Where(i => i != null).ToArray(); - InternalTriggers = value.Select(i => new Tuple(i, GetTrigger(i))).ToArray(); + SaveTriggers(triggerList); + + InternalTriggers = triggerList.Select(i => new Tuple(i, GetTrigger(i))).ToArray(); } } @@ -535,7 +538,8 @@ namespace Emby.Common.Implementations.ScheduledTasks /// IEnumerable{BaseTaskTrigger}. private Tuple[] LoadTriggers() { - var settings = LoadTriggerSettings(); + // This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly + var settings = LoadTriggerSettings().Where(i => i != null).ToArray(); return settings.Select(i => new Tuple(i, GetTrigger(i))).ToArray(); } @@ -544,8 +548,12 @@ namespace Emby.Common.Implementations.ScheduledTasks { try { - return JsonSerializer.DeserializeFromFile>(GetConfigurationFilePath()) - .ToArray(); + var list = JsonSerializer.DeserializeFromFile>(GetConfigurationFilePath()); + + if (list != null) + { + return list.ToArray(); + } } catch (FileNotFoundException) { @@ -555,8 +563,8 @@ namespace Emby.Common.Implementations.ScheduledTasks catch (DirectoryNotFoundException) { // File doesn't exist. No biggie. Return defaults. - return ScheduledTask.GetDefaultTriggers().ToArray(); } + return ScheduledTask.GetDefaultTriggers().ToArray(); } /// From 94451de6d2730e028724b16ac6fbc1b0dfb86ff5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 10:58:09 -0500 Subject: [PATCH 08/48] improve ScheduleDirect showId --- .../LiveTv/Listings/SchedulesDirect.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 04fc78c95..e2446b16f 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -422,7 +422,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings } var showType = details.showType ?? string.Empty; - + var info = new ProgramInfo { ChannelId = channel, @@ -440,10 +440,23 @@ namespace Emby.Server.Implementations.LiveTv.Listings IsKids = string.Equals(details.audience, "children", StringComparison.OrdinalIgnoreCase), IsSports = showType.IndexOf("sports", StringComparison.OrdinalIgnoreCase) != -1, IsMovie = showType.IndexOf("movie", StringComparison.OrdinalIgnoreCase) != -1 || showType.IndexOf("film", StringComparison.OrdinalIgnoreCase) != -1, - ShowId = programInfo.programID, Etag = programInfo.md5 }; + var showId = programInfo.programID ?? string.Empty; + + // According to SchedulesDirect, these are generic, unidentified episodes + // SH005316560000 + var hasUniqueShowId = !showId.StartsWith("SH", StringComparison.OrdinalIgnoreCase) || + !showId.EndsWith("0000", StringComparison.OrdinalIgnoreCase); + + if (!hasUniqueShowId) + { + showId = newID; + } + + info.ShowId = showId; + if (programInfo.videoProperties != null) { info.IsHD = programInfo.videoProperties.Contains("hdtv", StringComparer.OrdinalIgnoreCase); From f8c88aa632a91f3ca497fcb762f358410a490379 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 10:58:31 -0500 Subject: [PATCH 09/48] add null checks --- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 23e63dad0..116a6a7cf 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -95,6 +95,11 @@ namespace MediaBrowser.MediaEncoding.Encoder int defaultImageExtractionTimeoutMs, bool enableEncoderFontFile, IEnvironmentInfo environmentInfo) { + if (jsonSerializer == null) + { + throw new ArgumentNullException("jsonSerializer"); + } + _logger = logger; _jsonSerializer = jsonSerializer; ConfigurationManager = configurationManager; @@ -632,7 +637,7 @@ namespace MediaBrowser.MediaEncoding.Encoder var result = _jsonSerializer.DeserializeFromStream(process.StandardOutput.BaseStream); - if (result.streams == null && result.format == null) + if (result == null || (result.streams == null && result.format == null)) { throw new Exception("ffprobe failed - streams and format are both null."); } From 1186df23dda947821113c6d09598204ec5a0fdd8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 10:58:50 -0500 Subject: [PATCH 10/48] increase missing episode threshold --- MediaBrowser.Providers/TV/MissingEpisodeProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 4992675da..538512557 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -238,7 +238,7 @@ namespace MediaBrowser.Providers.TV var targetSeries = DetermineAppropriateSeries(series, tuple.Item1); var seasonOffset = TvdbSeriesProvider.GetSeriesOffset(targetSeries.ProviderIds) ?? ((targetSeries.AnimeSeriesIndex ?? 1) - 1); - var unairedThresholdDays = 1; + var unairedThresholdDays = 2; now = now.AddDays(0 - unairedThresholdDays); if (airDate.Value < now) From e4ceec749d6df5d2596fe63ccb727220957b9692 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 10:59:08 -0500 Subject: [PATCH 11/48] limit guide date picker to actual guide days --- Emby.Server.Implementations/LiveTv/LiveTvManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 525db4036..62a0738c7 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2647,7 +2647,7 @@ namespace Emby.Server.Implementations.LiveTv public GuideInfo GetGuideInfo() { var startDate = DateTime.UtcNow; - var endDate = startDate.AddDays(14); + var endDate = startDate.AddDays(GetGuideDays()); return new GuideInfo { From 009e860f6f6c939f1fb332d84d387f0e7f519858 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 11:47:43 -0500 Subject: [PATCH 12/48] limit http compression --- .../HttpServer/HttpResultFactory.cs | 81 +++++++++---------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index 995dc7b7b..e78446bc8 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -203,20 +203,12 @@ namespace Emby.Server.Implementations.HttpServer // Do not use the memoryStreamFactory here, they don't place nice with compression using (var ms = new MemoryStream()) { - using (var compressionStream = GetCompressionStream(ms, compressionType)) - { - ContentTypes.Instance.SerializeToStream(request, dto, compressionStream); - compressionStream.Dispose(); + ContentTypes.Instance.SerializeToStream(request, dto, ms); + ms.Position = 0; - var compressedBytes = ms.ToArray(); + var responseHeaders = new Dictionary(StringComparer.OrdinalIgnoreCase); - var httpResult = new StreamWriter(compressedBytes, request.ResponseContentType, _logger); - - //httpResult.Headers["Content-Length"] = compressedBytes.Length.ToString(UsCulture); - httpResult.Headers["Content-Encoding"] = compressionType; - - return httpResult; - } + return GetCompressedResult(ms, compressionType, responseHeaders, false, request.ResponseContentType).Result; } } @@ -591,45 +583,53 @@ namespace Emby.Server.Implementations.HttpServer }; } - string content; - using (var stream = await factoryFn().ConfigureAwait(false)) { - using (var reader = new StreamReader(stream)) - { - content = await reader.ReadToEndAsync().ConfigureAwait(false); - } + return await GetCompressedResult(stream, requestedCompressionType, responseHeaders, isHeadRequest, contentType).ConfigureAwait(false); } - - var contents = Compress(content, requestedCompressionType); - - responseHeaders["Content-Length"] = contents.Length.ToString(UsCulture); - responseHeaders["Content-Encoding"] = requestedCompressionType; - - if (isHeadRequest) - { - return GetHttpResult(new byte[] { }, contentType, true); - } - - return GetHttpResult(contents, contentType, true, responseHeaders); } - private byte[] Compress(string text, string compressionType) + private async Task GetCompressedResult(Stream stream, + string requestedCompressionType, + IDictionary responseHeaders, + bool isHeadRequest, + string contentType) + { + using (var reader = new MemoryStream()) + { + await stream.CopyToAsync(reader).ConfigureAwait(false); + + reader.Position = 0; + var content = reader.ToArray(); + + if (content.Length >= 1024) + { + content = Compress(content, requestedCompressionType); + responseHeaders["Content-Encoding"] = requestedCompressionType; + } + + responseHeaders["Content-Length"] = content.Length.ToString(UsCulture); + + if (isHeadRequest) + { + return GetHttpResult(new byte[] { }, contentType, true); + } + + return GetHttpResult(content, contentType, true, responseHeaders); + } + } + + private byte[] Compress(byte[] bytes, string compressionType) { if (compressionType == "deflate") - return Deflate(text); + return Deflate(bytes); if (compressionType == "gzip") - return GZip(text); + return GZip(bytes); throw new NotSupportedException(compressionType); } - private byte[] Deflate(string text) - { - return Deflate(Encoding.UTF8.GetBytes(text)); - } - private byte[] Deflate(byte[] bytes) { // In .NET FX incompat-ville, you can't access compressed bytes without closing DeflateStream @@ -644,11 +644,6 @@ namespace Emby.Server.Implementations.HttpServer } } - private byte[] GZip(string text) - { - return GZip(Encoding.UTF8.GetBytes(text)); - } - private byte[] GZip(byte[] buffer) { using (var ms = new MemoryStream()) From 3e8b54254f0c79794f0ca21fea5a6a04cda256f0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 11:47:53 -0500 Subject: [PATCH 13/48] update video params --- MediaBrowser.Api/Playback/Progressive/VideoService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index e29aa7d5a..7ae64b834 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -153,7 +153,7 @@ namespace MediaBrowser.Api.Playback.Progressive if (!state.RunTimeTicks.HasValue) { - args += " -fflags +genpts -flags +global_header"; + args += " -flags -global_header -fflags +genpts"; } return args; From c2d80791bed06c82204fe37a33a3c53654beee8f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 11:48:06 -0500 Subject: [PATCH 14/48] placeholder --- SocketHttpListener.Portable/Net/ResponseStream.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SocketHttpListener.Portable/Net/ResponseStream.cs b/SocketHttpListener.Portable/Net/ResponseStream.cs index 6067a89ec..a79a18791 100644 --- a/SocketHttpListener.Portable/Net/ResponseStream.cs +++ b/SocketHttpListener.Portable/Net/ResponseStream.cs @@ -136,6 +136,11 @@ namespace SocketHttpListener.Net if (disposed) throw new ObjectDisposedException(GetType().ToString()); + if (count == 0) + { + //return; + } + byte[] bytes = null; MemoryStream ms = GetHeaders(response, _memoryStreamFactory, false); bool chunked = response.SendChunked; @@ -176,6 +181,11 @@ namespace SocketHttpListener.Net if (disposed) throw new ObjectDisposedException(GetType().ToString()); + if (count == 0) + { + //return; + } + byte[] bytes = null; MemoryStream ms = GetHeaders(response, _memoryStreamFactory, false); bool chunked = response.SendChunked; @@ -206,7 +216,7 @@ namespace SocketHttpListener.Net await stream.WriteAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false); } - if (response.SendChunked) + if (chunked) stream.Write(crlf, 0, 2); } From 982d4cbb3eb9f10706399aae196e3213a03930ef Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 11:48:24 -0500 Subject: [PATCH 15/48] update comparisons --- SocketHttpListener.Portable/Net/HttpListenerResponse.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SocketHttpListener.Portable/Net/HttpListenerResponse.cs b/SocketHttpListener.Portable/Net/HttpListenerResponse.cs index c1182de34..9a5862cb9 100644 --- a/SocketHttpListener.Portable/Net/HttpListenerResponse.cs +++ b/SocketHttpListener.Portable/Net/HttpListenerResponse.cs @@ -386,7 +386,7 @@ namespace SocketHttpListener.Net if (content_type != null) { - if (content_encoding != null && content_type.IndexOf("charset=", StringComparison.Ordinal) == -1) + if (content_encoding != null && content_type.IndexOf("charset=", StringComparison.OrdinalIgnoreCase) == -1) { string enc_name = content_encoding.WebName; headers.SetInternal("Content-Type", content_type + "; charset=" + enc_name); @@ -429,9 +429,10 @@ namespace SocketHttpListener.Net * HttpStatusCode.InternalServerError 500 * HttpStatusCode.ServiceUnavailable 503 */ - bool conn_close = (status_code == 408 || status_code == 411 || + bool conn_close = status_code == 400 || status_code == 408 || status_code == 411 || status_code == 413 || status_code == 414 || - status_code == 503); + status_code == 500 || + status_code == 503; if (conn_close == false) conn_close = !context.Request.KeepAlive; From 02f749c654a5af4525304ed3ee470ba40c6405b9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Dec 2016 18:53:57 -0500 Subject: [PATCH 16/48] update shortcut handling --- .../Library/Resolvers/Movies/MovieResolver.cs | 27 +++++--- .../Native/LnkShortcutHandler.cs | 69 +------------------ .../WindowsAppHost.cs | 24 +++++-- 3 files changed, 38 insertions(+), 82 deletions(-) diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 55a63b4e5..b791311f9 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -74,21 +74,21 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { - return ResolveVideos(parent, files, directoryService, false); + return ResolveVideos(parent, files, directoryService, false, collectionType); } if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) || string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) { - return ResolveVideos