From 4f32b57e58b0568c7c0112146e87633c965efe88 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 27 Jul 2016 13:11:25 -0400 Subject: update buffer sizes --- MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs | 3 +-- MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs index 7ac92408b..71cd20743 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -28,8 +28,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer public Action OnComplete { get; set; } private readonly ILogger _logger; - // 256k - private const int BufferSize = 262144; + private const int BufferSize = 81920; /// /// The _options diff --git a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs index f5906f6b7..ae408f8d6 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs @@ -75,8 +75,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { } - // 256k - private const int BufferSize = 262144; + private const int BufferSize = 81920; /// /// Writes to. -- cgit v1.2.3 From 1bd3b22c811bea35bb2779d8f6e322e074bd47cc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 30 Jul 2016 13:52:06 -0400 Subject: update service stack config --- MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 17e4793cb..4121c5e5e 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -67,6 +67,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer public override void Configure(Container container) { HostConfig.Instance.DefaultRedirectPath = DefaultRedirectPath; + HostConfig.Instance.LogUnobservedTaskExceptions = false; HostConfig.Instance.MapExceptionToStatusCode = new Dictionary { @@ -80,7 +81,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer {typeof (ApplicationException), 500} }; - HostConfig.Instance.DebugMode = true; + HostConfig.Instance.DebugMode = false; HostConfig.Instance.LogFactory = LogManager.LogFactory; -- cgit v1.2.3 From 23da61281ee108954de9799761fa9c78dc4547ce Mon Sep 17 00:00:00 2001 From: softworkz Date: Fri, 5 Aug 2016 23:15:48 +0200 Subject: Reduced compiler warnings. No functional changes (except MediaEncoder.cs and AutomaticRestartEntryPoint.cs) --- MediaBrowser.Api/ApiEntryPoint.cs | 4 ++-- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/PluginService.cs | 2 +- MediaBrowser.Common/Plugins/BasePlugin.cs | 2 +- MediaBrowser.LocalMetadata/BaseXmlProvider.cs | 2 +- MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs | 2 +- MediaBrowser.Server.Implementations/Connect/ConnectManager.cs | 2 +- MediaBrowser.Server.Implementations/Dto/DtoService.cs | 2 +- .../EntryPoints/ActivityLogEntryPoint.cs | 2 +- .../EntryPoints/ExternalPortForwarding.cs | 2 +- .../EntryPoints/UserDataChangeNotifier.cs | 2 +- MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs | 2 +- .../HttpServer/RangeRequestWriter.cs | 2 +- MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs | 4 ++-- .../LiveTv/EmbyTV/ItemDataProvider.cs | 2 +- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 2 +- .../LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs | 2 +- .../Notifications/SqliteNotificationsRepository.cs | 2 +- MediaBrowser.Server.Startup.Common/ApplicationHost.cs | 6 +++--- 20 files changed, 24 insertions(+), 24 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 87fa3d46c..dbc1179e2 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -559,13 +559,13 @@ namespace MediaBrowser.Api { } - catch (IOException ex) + catch (IOException) { //Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); DeletePartialStreamFiles(path, jobType, retryCount + 1, 500); } - catch (Exception ex) + catch { //Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index ab73aabe4..a5f78420c 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1080,7 +1080,7 @@ namespace MediaBrowser.Api.Playback //process.BeginOutputReadLine(); // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback - Task.Run(() => StartStreamingLog(transcodingJob, state, process.StandardError.BaseStream, state.LogFileStream)); + var task = Task.Run(() => StartStreamingLog(transcodingJob, state, process.StandardError.BaseStream, state.LogFileStream)); // Wait for the file to exist before proceeeding while (!FileSystem.FileExists(state.WaitForPath ?? outputPath) && !transcodingJob.HasExited) diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 3bf70715f..7ad69fd04 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -227,7 +227,7 @@ namespace MediaBrowser.Api .ToList(); } } - catch (Exception ex) + catch { //Logger.ErrorException("Error getting plugin list", ex); // Play it safe here diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs index a0716137b..b75accf9b 100644 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ b/MediaBrowser.Common/Plugins/BasePlugin.cs @@ -211,7 +211,7 @@ namespace MediaBrowser.Common.Plugins { return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType)); } - catch (Exception ex) + catch { return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType)); } diff --git a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs index 0289ffb08..f23559e4b 100644 --- a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs +++ b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs @@ -75,7 +75,7 @@ namespace MediaBrowser.LocalMetadata } } - public int Order + public virtual int Order { get { diff --git a/MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs b/MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs index 8f9d21eae..0893f192f 100644 --- a/MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs +++ b/MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs @@ -31,7 +31,7 @@ namespace MediaBrowser.LocalMetadata.Providers return directoryService.GetFile(Path.Combine(info.Path, "series.xml")); } - public int Order + public override int Order { get { diff --git a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs index d7ef493c2..71306e0ec 100644 --- a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs +++ b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs @@ -58,7 +58,7 @@ namespace MediaBrowser.MediaEncoding.Encoder else { // Kick this off, but no need to wait on it - Task.Run(async () => + var task = Task.Run(async () => { await DownloadFontFile(fontsDirectory, fontFilename, new Progress()).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 24750de94..4e913cf99 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -151,7 +151,7 @@ namespace MediaBrowser.Server.Implementations.Connect { DiscoveredWanIpAddress = address; - UpdateConnectInfo(); + var task = UpdateConnectInfo(); } private async Task UpdateConnectInfo() diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 779afdcf2..cc165da6a 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1620,7 +1620,7 @@ namespace MediaBrowser.Server.Implementations.Dto { size = _imageProcessor.GetImageSize(imageInfo); } - catch (Exception ex) + catch { //_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path); return null; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs index 46ddf3dd8..a36583a41 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints private readonly IInstallationManager _installationManager; //private readonly ILogManager _logManager; - private readonly ILogger _logger; + //private readonly ILogger _logger; private readonly ISessionManager _sessionManager; private readonly ITaskManager _taskManager; private readonly IActivityManager _activityManager; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 64e3c56a6..280bec65b 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -165,7 +165,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints CreateRules(device); } - catch (Exception ex) + catch { // I think it could be a good idea to log the exception because // you are using permanent portmapping here (never expire) and that means that next time diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index b616b7761..2bb010133 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints var changes = _changedItems.ToList(); _changedItems.Clear(); - SendNotifications(changes, CancellationToken.None); + var task = SendNotifications(changes, CancellationToken.None); if (UpdateTimer != null) { diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 4121c5e5e..5cf0a246f 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -251,7 +251,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer httpRes.Close(); } - catch (Exception errorEx) + catch { //_logger.ErrorException("Error this.ProcessRequest(context)(Exception while writing error to the response)", errorEx); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs index 71cd20743..488c630fe 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -191,7 +191,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } } - catch (IOException ex) + catch (IOException) { throw; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index a36eae8d2..ee8ab7c25 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -55,8 +55,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV public static EmbyTV Current; - public event EventHandler DataSourceChanged; - public event EventHandler RecordingStatusChanged; + public event EventHandler DataSourceChanged { add { } remove { } } + public event EventHandler RecordingStatusChanged { add { } remove { } } private readonly ConcurrentDictionary _activeRecordings = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 79b26468e..7fe271bea 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -52,7 +52,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV catch (FileNotFoundException) { } - catch (DirectoryNotFoundException ex) + catch (DirectoryNotFoundException) { } catch (IOException ex) diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 69b6fb5a9..fd4775938 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -431,7 +431,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun list.Add(await GetMediaSource(info, hdhrId, "mobile").ConfigureAwait(false)); } } - catch (Exception ex) + catch { } diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs index 71b3f8a18..0f8682b7c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs @@ -649,7 +649,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.Rtsp #region Public Events - public event PropertyChangedEventHandler PropertyChanged; + ////public event PropertyChangedEventHandler PropertyChanged; #endregion diff --git a/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs b/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs index be8c6d48d..f30ba3e54 100644 --- a/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs +++ b/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Server.Implementations.Notifications public event EventHandler NotificationAdded; public event EventHandler NotificationsMarkedRead; - public event EventHandler NotificationUpdated; + ////public event EventHandler NotificationUpdated; public async Task Initialize() { diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 3f1f98cd0..ce99f0a24 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -606,7 +606,7 @@ namespace MediaBrowser.Server.Startup.Common { return new ImageMagickEncoder(LogManager.GetLogger("ImageMagick"), ApplicationPaths, HttpClient, FileSystemManager, ServerConfigurationManager); } - catch (Exception ex) + catch { Logger.Error("Error loading ImageMagick. Will revert to GDI."); } @@ -616,7 +616,7 @@ namespace MediaBrowser.Server.Startup.Common { return new GDIImageEncoder(FileSystemManager, LogManager.GetLogger("GDI")); } - catch (Exception ex) + catch { Logger.Error("Error loading GDI. Will revert to NullImageEncoder."); } @@ -1412,7 +1412,7 @@ namespace MediaBrowser.Server.Startup.Common { return new Uri(externalDns).Host; } - catch (Exception e) + catch { return externalDns; } -- cgit v1.2.3 From 433254c498d2e43acfd34e5c4fcee2fdcc2e767b Mon Sep 17 00:00:00 2001 From: softworkz Date: Fri, 5 Aug 2016 06:08:11 +0200 Subject: Async stream handling: Use interface instead of Func No functional changes --- .../Progressive/BaseProgressiveStreamingService.cs | 4 +- .../Progressive/ProgressiveStreamWriter.cs | 23 +++- .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Controller/Net/IAsyncStreamSource.cs | 18 +++ MediaBrowser.Controller/Net/IHttpResultFactory.cs | 2 +- .../HttpServer/AsyncStreamWriter.cs | 59 ++++++++ .../HttpServer/AsyncStreamWriterEx.cs | 153 +++++++++++++++++++++ .../HttpServer/AsyncStreamWriterFunc.cs | 56 -------- .../HttpServer/HttpResultFactory.cs | 9 +- .../MediaBrowser.Server.Implementations.csproj | 3 +- 10 files changed, 263 insertions(+), 65 deletions(-) create mode 100644 MediaBrowser.Controller/Net/IAsyncStreamSource.cs create mode 100644 MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriter.cs create mode 100644 MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterEx.cs delete mode 100644 MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterFunc.cs (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 4649499c4..5a5cb8000 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -362,9 +362,9 @@ namespace MediaBrowser.Api.Playback.Progressive outputHeaders[item.Key] = item.Value; } - Func streamWriter = stream => new ProgressiveFileCopier(FileSystem, job, Logger).StreamFile(outputPath, stream, CancellationToken.None); + var streamSource = new ProgressiveFileCopier(FileSystem, outputPath, outputHeaders, job, Logger, CancellationToken.None); - return ResultFactory.GetAsyncStreamWriter(streamWriter, outputHeaders); + return ResultFactory.GetAsyncStreamWriter(streamSource); } finally { diff --git a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs index 63d71b85e..8c4e23a39 100644 --- a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs +++ b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs @@ -4,28 +4,45 @@ using System.IO; using System.Threading; using System.Threading.Tasks; using CommonIO; +using MediaBrowser.Controller.Net; +using System.Collections.Generic; +using ServiceStack.Web; namespace MediaBrowser.Api.Playback.Progressive { - public class ProgressiveFileCopier + public class ProgressiveFileCopier : IAsyncStreamSource, IHasOptions { private readonly IFileSystem _fileSystem; private readonly TranscodingJob _job; private readonly ILogger _logger; + private readonly string _path; + private readonly CancellationToken _cancellationToken; + private readonly Dictionary _outputHeaders; // 256k private const int BufferSize = 81920; private long _bytesWritten = 0; - public ProgressiveFileCopier(IFileSystem fileSystem, TranscodingJob job, ILogger logger) + public ProgressiveFileCopier(IFileSystem fileSystem, string path, Dictionary outputHeaders, TranscodingJob job, ILogger logger, CancellationToken cancellationToken) { _fileSystem = fileSystem; + _path = path; + _outputHeaders = outputHeaders; _job = job; _logger = logger; + _cancellationToken = cancellationToken; } - public async Task StreamFile(string path, Stream outputStream, CancellationToken cancellationToken) + public IDictionary Options + { + get + { + return _outputHeaders; + } + } + + public async Task WriteToAsync(Stream outputStream) { try { diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 0462117cb..e7eaa1dc0 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -236,6 +236,7 @@ + diff --git a/MediaBrowser.Controller/Net/IAsyncStreamSource.cs b/MediaBrowser.Controller/Net/IAsyncStreamSource.cs new file mode 100644 index 000000000..0f41f60a5 --- /dev/null +++ b/MediaBrowser.Controller/Net/IAsyncStreamSource.cs @@ -0,0 +1,18 @@ +using ServiceStack.Web; +using System.IO; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Net +{ + /// + /// Interface IAsyncStreamSource + /// Enables asynchronous writing to http resonse streams + /// + public interface IAsyncStreamSource + { + /// + /// Asynchronously write to the response stream. + /// + Task WriteToAsync(Stream responseStream); + } +} diff --git a/MediaBrowser.Controller/Net/IHttpResultFactory.cs b/MediaBrowser.Controller/Net/IHttpResultFactory.cs index 49d4614d8..8fdb1ce37 100644 --- a/MediaBrowser.Controller/Net/IHttpResultFactory.cs +++ b/MediaBrowser.Controller/Net/IHttpResultFactory.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.Controller.Net /// System.Object. object GetResult(object content, string contentType, IDictionary responseHeaders = null); - object GetAsyncStreamWriter(Func streamWriter, IDictionary responseHeaders = null); + object GetAsyncStreamWriter(IAsyncStreamSource streamSource); /// /// Gets the optimized result. diff --git a/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriter.cs new file mode 100644 index 000000000..e44b0c6af --- /dev/null +++ b/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriter.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using ServiceStack; +using ServiceStack.Web; +using MediaBrowser.Controller.Net; + +namespace MediaBrowser.Server.Implementations.HttpServer +{ + public class AsyncStreamWriter : IStreamWriter, IAsyncStreamWriter, IHasOptions + { + /// + /// Gets or sets the source stream. + /// + /// The source stream. + private IAsyncStreamSource _source; + + public Action OnComplete { get; set; } + public Action OnError { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public AsyncStreamWriter(IAsyncStreamSource source) + { + _source = source; + } + + public IDictionary Options + { + get + { + var hasOptions = _source as IHasOptions; + if (hasOptions != null) + { + return hasOptions.Options; + } + + return new Dictionary(StringComparer.OrdinalIgnoreCase); + } + } + + /// + /// Writes to. + /// + /// The response stream. + public void WriteTo(Stream responseStream) + { + var task = _source.WriteToAsync(responseStream); + Task.WaitAll(task); + } + + public async Task WriteToAsync(Stream responseStream) + { + await _source.WriteToAsync(responseStream).ConfigureAwait(false); + } + } +} diff --git a/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterEx.cs b/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterEx.cs new file mode 100644 index 000000000..b98addb31 --- /dev/null +++ b/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterEx.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using ServiceStack; +using ServiceStack.Web; +using MediaBrowser.Controller.Net; + +namespace MediaBrowser.Server.Implementations.HttpServer +{ + public class AsyncStreamWriterEx : AsyncStreamWriter, IHttpResult + { + /// + /// Gets or sets the source stream. + /// + /// The source stream. + private IAsyncStreamSource _source; + + /// + /// Initializes a new instance of the class. + /// + public AsyncStreamWriterEx(IAsyncStreamSource source) : base(source) + { + _source = source; + } + + public string ContentType + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public List Cookies + { + get { throw new NotImplementedException(); } + } + + public Dictionary Headers + { + get { throw new NotImplementedException(); } + } + + public int PaddingLength + { + get + { + return Result.PaddingLength; + } + set + { + Result.PaddingLength = value; + } + } + + public IRequest RequestContext + { + get + { + return Result.RequestContext; + } + set + { + Result.RequestContext = value; + } + } + + public object Response + { + get + { + return Result.Response; + } + set + { + Result.Response = value; + } + } + + public IContentTypeWriter ResponseFilter + { + get + { + return Result.ResponseFilter; + } + set + { + Result.ResponseFilter = value; + } + } + + public Func ResultScope + { + get + { + return Result.ResultScope; + } + set + { + Result.ResultScope = value; + } + } + + public int Status + { + get + { + return Result.Status; + } + set + { + Result.Status = value; + } + } + + public System.Net.HttpStatusCode StatusCode + { + get + { + return Result.StatusCode; + } + set + { + Result.StatusCode = value; + } + } + + public string StatusDescription + { + get + { + return Result.StatusDescription; + } + set + { + Result.StatusDescription = value; + } + } + + private IHttpResult Result + { + get + { + return _source as IHttpResult; + } + } + } +} diff --git a/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterFunc.cs b/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterFunc.cs deleted file mode 100644 index 5aa01c706..000000000 --- a/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterFunc.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; -using ServiceStack; -using ServiceStack.Web; - -namespace MediaBrowser.Server.Implementations.HttpServer -{ - public class AsyncStreamWriterFunc : IStreamWriter, IAsyncStreamWriter, IHasOptions - { - /// - /// Gets or sets the source stream. - /// - /// The source stream. - private Func Writer { get; set; } - - /// - /// Gets the options. - /// - /// The options. - public IDictionary Options { get; private set; } - - public Action OnComplete { get; set; } - public Action OnError { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public AsyncStreamWriterFunc(Func writer, IDictionary headers) - { - Writer = writer; - - if (headers == null) - { - headers = new Dictionary(StringComparer.OrdinalIgnoreCase); - } - Options = headers; - } - - /// - /// Writes to. - /// - /// The response stream. - public void WriteTo(Stream responseStream) - { - var task = Writer(responseStream); - Task.WaitAll(task); - } - - public async Task WriteToAsync(Stream responseStream) - { - await Writer(responseStream).ConfigureAwait(false); - } - } -} diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index c0a2a5eb3..f234674d8 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -704,9 +704,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer throw error; } - public object GetAsyncStreamWriter(Func streamWriter, IDictionary responseHeaders = null) + public object GetAsyncStreamWriter(IAsyncStreamSource streamSource) { - return new AsyncStreamWriterFunc(streamWriter, responseHeaders); + if (streamSource as IHttpResult != null) + { + return new AsyncStreamWriterEx(streamSource); + } + + return new AsyncStreamWriter(streamSource); } } } \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index dca753193..8025e3594 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -156,7 +156,8 @@ - + + -- cgit v1.2.3 From 7d16988b1b81cc73608c07d61eabb83f8fcbbb05 Mon Sep 17 00:00:00 2001 From: softworkz Date: Fri, 5 Aug 2016 19:07:43 +0200 Subject: Remove handling IHttpResult --- .../HttpServer/AsyncStreamWriterEx.cs | 153 --------------------- .../HttpServer/HttpResultFactory.cs | 5 - .../MediaBrowser.Server.Implementations.csproj | 1 - 3 files changed, 159 deletions(-) delete mode 100644 MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterEx.cs (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterEx.cs b/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterEx.cs deleted file mode 100644 index b98addb31..000000000 --- a/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterEx.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; -using ServiceStack; -using ServiceStack.Web; -using MediaBrowser.Controller.Net; - -namespace MediaBrowser.Server.Implementations.HttpServer -{ - public class AsyncStreamWriterEx : AsyncStreamWriter, IHttpResult - { - /// - /// Gets or sets the source stream. - /// - /// The source stream. - private IAsyncStreamSource _source; - - /// - /// Initializes a new instance of the class. - /// - public AsyncStreamWriterEx(IAsyncStreamSource source) : base(source) - { - _source = source; - } - - public string ContentType - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - - public List Cookies - { - get { throw new NotImplementedException(); } - } - - public Dictionary Headers - { - get { throw new NotImplementedException(); } - } - - public int PaddingLength - { - get - { - return Result.PaddingLength; - } - set - { - Result.PaddingLength = value; - } - } - - public IRequest RequestContext - { - get - { - return Result.RequestContext; - } - set - { - Result.RequestContext = value; - } - } - - public object Response - { - get - { - return Result.Response; - } - set - { - Result.Response = value; - } - } - - public IContentTypeWriter ResponseFilter - { - get - { - return Result.ResponseFilter; - } - set - { - Result.ResponseFilter = value; - } - } - - public Func ResultScope - { - get - { - return Result.ResultScope; - } - set - { - Result.ResultScope = value; - } - } - - public int Status - { - get - { - return Result.Status; - } - set - { - Result.Status = value; - } - } - - public System.Net.HttpStatusCode StatusCode - { - get - { - return Result.StatusCode; - } - set - { - Result.StatusCode = value; - } - } - - public string StatusDescription - { - get - { - return Result.StatusDescription; - } - set - { - Result.StatusDescription = value; - } - } - - private IHttpResult Result - { - get - { - return _source as IHttpResult; - } - } - } -} diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index f234674d8..b26cf5b76 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -706,11 +706,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer public object GetAsyncStreamWriter(IAsyncStreamSource streamSource) { - if (streamSource as IHttpResult != null) - { - return new AsyncStreamWriterEx(streamSource); - } - return new AsyncStreamWriter(streamSource); } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 8025e3594..07cb9fa0d 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -156,7 +156,6 @@ - -- cgit v1.2.3 From ce26f24ec7e7a1828e1bfa4c5d6377a37da433b9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 8 Aug 2016 00:35:21 -0400 Subject: remove X-Powered-By header --- MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 5cf0a246f..90055d8ec 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -81,6 +81,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer {typeof (ApplicationException), 500} }; + HostConfig.Instance.GlobalResponseHeaders = new Dictionary(); HostConfig.Instance.DebugMode = false; HostConfig.Instance.LogFactory = LogManager.LogFactory; -- cgit v1.2.3 From 319dcda4beb5cde9cd858a33a9603f0cff54d831 Mon Sep 17 00:00:00 2001 From: Softworkz Date: Sat, 13 Aug 2016 06:57:21 +0200 Subject: Fix: ETag-Values MUST be quoted according to W3C spec --- MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index c0a2a5eb3..194904320 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -275,7 +275,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// System.Object. private object GetCachedResult(IRequest requestContext, IDictionary responseHeaders, Guid cacheKey, string cacheKeyString, DateTime? lastDateModified, TimeSpan? cacheDuration, string contentType) { - responseHeaders["ETag"] = cacheKeyString; + responseHeaders["ETag"] = string.Format("\"{0}\"", cacheKeyString); if (IsNotModified(requestContext, cacheKey, lastDateModified, cacheDuration)) { -- cgit v1.2.3 From 7dbeeadea6edff204276bf87c03c85886d0ff321 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 13 Aug 2016 20:52:32 -0400 Subject: fix lastmodified header --- MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index 194904320..27065d0f5 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -534,7 +534,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (lastDateModified.HasValue && (string.IsNullOrEmpty(cacheKey) || cacheDuration.HasValue)) { AddAgeHeader(responseHeaders, lastDateModified); - responseHeaders["LastModified"] = lastDateModified.Value.ToString("r"); + responseHeaders["Last-Modified"] = lastDateModified.Value.ToString("r"); } if (cacheDuration.HasValue) -- cgit v1.2.3 From 389487638ec358c975f7573c8b6132525f3925ab Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 18 Aug 2016 02:26:47 -0400 Subject: fixes #1851 - EmbyServer crashes if staticly assigned IP address changes --- .../HttpServer/HttpListenerHost.cs | 50 ++++++++++++++++++++++ .../ApplicationHost.cs | 35 +-------------- 2 files changed, 52 insertions(+), 33 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 90055d8ec..633208739 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -331,6 +331,46 @@ namespace MediaBrowser.Server.Implementations.HttpServer return url; } + private string NormalizeConfiguredLocalAddress(string address) + { + var index = address.Trim('/').IndexOf('/'); + + if (index != -1) + { + address = address.Substring(index + 1); + } + + return address.Trim('/'); + } + + private bool ValidateHost(Uri url) + { + var hosts = _config + .Configuration + .LocalNetworkAddresses + .Select(NormalizeConfiguredLocalAddress) + .ToList(); + + if (hosts.Count == 0) + { + return true; + } + + var host = url.Host ?? string.Empty; + + _logger.Debug("Validating host {0}", host); + + if (_networkManager.IsInPrivateAddressSpace(host)) + { + hosts.Add("localhost"); + hosts.Add("127.0.0.1"); + + return hosts.Any(i => host.IndexOf(i, StringComparison.OrdinalIgnoreCase) != -1); + } + + return true; + } + /// /// Overridable method that can be used to implement a custom hnandler /// @@ -350,6 +390,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer return ; } + if (!ValidateHost(url)) + { + httpRes.StatusCode = 400; + httpRes.ContentType = "text/plain"; + httpRes.Write("Invalid host"); + + httpRes.Close(); + return; + } + var operationName = httpReq.OperationName; var localPath = url.LocalPath; diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 74438abbc..9eb8a4736 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -821,42 +821,11 @@ namespace MediaBrowser.Server.Startup.Common private string CertificatePath { get; set; } - private string NormalizeConfiguredLocalAddress(string address) - { - var index = address.Trim('/').IndexOf('/'); - - if (index != -1) - { - address = address.Substring(index + 1); - } - - return address.Trim('/'); - } private IEnumerable GetUrlPrefixes() { - var hosts = ServerConfigurationManager - .Configuration - .LocalNetworkAddresses - .Select(NormalizeConfiguredLocalAddress) - .ToList(); + var hosts = new List(); - if (hosts.Count == 0) - { - hosts.Add("+"); - } - - if (!hosts.Contains("+", StringComparer.OrdinalIgnoreCase)) - { - if (!hosts.Contains("localhost", StringComparer.OrdinalIgnoreCase)) - { - hosts.Add("localhost"); - } - - if (!hosts.Contains("127.0.0.1", StringComparer.OrdinalIgnoreCase)) - { - hosts.Add("127.0.0.1"); - } - } + hosts.Add("+"); return hosts.SelectMany(i => { -- cgit v1.2.3 From 430b187ef6b7d550e9ade89dd0254c5d1448a77a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 22 Aug 2016 14:28:24 -0400 Subject: start a dashboard folder --- .../Updates/GithubUpdater.cs | 1 - .../Configuration/ServerConfiguration.cs | 2 + .../HttpServer/HttpListenerHost.cs | 20 ++++- .../ApplicationHost.cs | 1 + .../MediaBrowser.Server.Startup.Common.csproj | 1 + .../Migrations/UpdateLevelMigration.cs | 97 ++++++++++++++++++++++ MediaBrowser.WebDashboard/Api/DashboardService.cs | 62 ++++++++------ .../MediaBrowser.WebDashboard.csproj | 34 ++++---- .../Savers/EpisodeNfoSaver.cs | 4 +- 9 files changed, 180 insertions(+), 42 deletions(-) create mode 100644 MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Common.Implementations/Updates/GithubUpdater.cs b/MediaBrowser.Common.Implementations/Updates/GithubUpdater.cs index d1ec30210..a118f7c26 100644 --- a/MediaBrowser.Common.Implementations/Updates/GithubUpdater.cs +++ b/MediaBrowser.Common.Implementations/Updates/GithubUpdater.cs @@ -33,7 +33,6 @@ namespace MediaBrowser.Common.Implementations.Updates EnableKeepAlive = false, CancellationToken = cancellationToken, UserAgent = "Emby/3.0" - }; if (_cacheLength.Ticks > 0) diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 63d452bce..a891a422a 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -74,6 +74,8 @@ namespace MediaBrowser.Model.Configuration /// The metadata path. public string MetadataPath { get; set; } + public string LastVersion { get; set; } + /// /// Gets or sets the display name of the season zero. /// diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 633208739..51a53fe21 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -428,8 +428,24 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase) || string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase) || - localPath.IndexOf("mediabrowser/web", StringComparison.OrdinalIgnoreCase) != -1 || - localPath.IndexOf("dashboard/", StringComparison.OrdinalIgnoreCase) != -1) + localPath.IndexOf("mediabrowser/web", StringComparison.OrdinalIgnoreCase) != -1) + { + httpRes.StatusCode = 200; + httpRes.ContentType = "text/html"; + var newUrl = urlString.Replace("mediabrowser", "emby", StringComparison.OrdinalIgnoreCase) + .Replace("/dashboard/", "/web/", StringComparison.OrdinalIgnoreCase); + + if (!string.Equals(newUrl, urlString, StringComparison.OrdinalIgnoreCase)) + { + httpRes.Write("EmbyPlease update your Emby bookmark to " + newUrl + ""); + + httpRes.Close(); + return; + } + } + + if (localPath.IndexOf("dashboard/", StringComparison.OrdinalIgnoreCase) != -1 && + localPath.IndexOf("web/dashboard", StringComparison.OrdinalIgnoreCase) == -1) { httpRes.StatusCode = 200; httpRes.ContentType = "text/html"; diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 8cb1d4f0d..8516e54ee 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -385,6 +385,7 @@ namespace MediaBrowser.Server.Startup.Common new OmdbEpisodeProviderMigration(ServerConfigurationManager), new MovieDbEpisodeProviderMigration(ServerConfigurationManager), new DbMigration(ServerConfigurationManager, TaskManager), + new UpdateLevelMigration(ServerConfigurationManager, this, HttpClient, JsonSerializer, _releaseAssetFilename), new FolderViewSettingMigration(ServerConfigurationManager, UserManager), new CollectionGroupingMigration(ServerConfigurationManager, UserManager), new CollectionsViewMigration(ServerConfigurationManager, UserManager) diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj index 808d25fc9..979a3a357 100644 --- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj +++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj @@ -77,6 +77,7 @@ + diff --git a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs new file mode 100644 index 000000000..fa354065c --- /dev/null +++ b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs @@ -0,0 +1,97 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Common.Implementations.Updates; +using MediaBrowser.Common.Net; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Updates; + +namespace MediaBrowser.Server.Startup.Common.Migrations +{ + public class UpdateLevelMigration : IVersionMigration + { + private readonly IServerConfigurationManager _config; + private readonly IServerApplicationHost _appHost; + private readonly IHttpClient _httpClient; + private readonly IJsonSerializer _jsonSerializer; + private readonly string _releaseAssetFilename; + + public UpdateLevelMigration(IServerConfigurationManager config, IServerApplicationHost appHost, IHttpClient httpClient, IJsonSerializer jsonSerializer, string releaseAssetFilename) + { + _config = config; + _appHost = appHost; + _httpClient = httpClient; + _jsonSerializer = jsonSerializer; + _releaseAssetFilename = releaseAssetFilename; + } + + public async void Run() + { + var lastVersion = _config.Configuration.LastVersion; + var currentVersion = _appHost.ApplicationVersion; + + if (string.Equals(lastVersion, currentVersion.ToString(), StringComparison.OrdinalIgnoreCase)) + { + return; + } + + try + { + var updateLevel = _config.Configuration.SystemUpdateLevel; + + // Go down a level + if (updateLevel == PackageVersionClass.Release) + { + updateLevel = PackageVersionClass.Beta; + } + else if (updateLevel == PackageVersionClass.Beta) + { + updateLevel = PackageVersionClass.Dev; + } + else if (updateLevel == PackageVersionClass.Dev) + { + // It's already dev, there's nothing to check + return; + } + + await CheckVersion(currentVersion, updateLevel, CancellationToken.None).ConfigureAwait(false); + } + catch + { + + } + } + + private async Task CheckVersion(Version currentVersion, PackageVersionClass updateLevel, CancellationToken cancellationToken) + { + var result = await new GithubUpdater(_httpClient, _jsonSerializer, TimeSpan.FromMinutes(5)) + .CheckForUpdateResult("MediaBrowser", "Emby", currentVersion, PackageVersionClass.Beta, _releaseAssetFilename, "MBServer", "Mbserver.zip", + cancellationToken).ConfigureAwait(false); + + if (result != null && result.IsUpdateAvailable) + { + _config.Configuration.SystemUpdateLevel = updateLevel; + _config.SaveConfiguration(); + return; + } + + // Go down a level + if (updateLevel == PackageVersionClass.Release) + { + updateLevel = PackageVersionClass.Beta; + } + else if (updateLevel == PackageVersionClass.Beta) + { + updateLevel = PackageVersionClass.Dev; + } + else + { + return; + } + + await CheckVersion(currentVersion, updateLevel, cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 12e1eb5ea..aec4632ae 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -157,11 +157,21 @@ namespace MediaBrowser.WebDashboard.Api var creator = GetPackageCreator(); var directory = creator.DashboardUIPath; - var skipExtensions = GetUndeployedExtensions(); + var skipExtensions = GetDeployIgnoreExtensions(); + var skipNames = GetDeployIgnoreFilenames(); return Directory.GetFiles(directory, "*", SearchOption.AllDirectories) .Where(i => !skipExtensions.Contains(Path.GetExtension(i) ?? string.Empty, StringComparer.OrdinalIgnoreCase)) + .Where(i => !skipNames.Any(s => + { + if (s.Item2) + { + return string.Equals(s.Item1, Path.GetFileName(i), StringComparison.OrdinalIgnoreCase); + } + + return (Path.GetFileName(i) ?? string.Empty).IndexOf(s.Item1, StringComparison.OrdinalIgnoreCase) != -1; + })) .Select(i => i.Replace(directory, string.Empty, StringComparison.OrdinalIgnoreCase).Replace("\\", "/").TrimStart('/') + "?v=" + _appHost.ApplicationVersion.ToString()) .ToList(); } @@ -300,7 +310,7 @@ namespace MediaBrowser.WebDashboard.Api return new PackageCreator(_fileSystem, _localization, Logger, _serverConfigurationManager, _jsonSerializer); } - private List GetUndeployedExtensions() + private List GetDeployIgnoreExtensions() { var list = new List(); @@ -315,6 +325,28 @@ namespace MediaBrowser.WebDashboard.Api return list; } + private List> GetDeployIgnoreFilenames() + { + var list = new List>(); + + list.Add(new Tuple("copying", true)); + list.Add(new Tuple("license", true)); + list.Add(new Tuple("license-mit", true)); + list.Add(new Tuple("gitignore", false)); + list.Add(new Tuple("npmignore", false)); + list.Add(new Tuple("jshintrc", false)); + list.Add(new Tuple("gruntfile", false)); + list.Add(new Tuple("bowerrc", false)); + list.Add(new Tuple("jscsrc", false)); + list.Add(new Tuple("hero.svg", false)); + list.Add(new Tuple("travis.yml", false)); + list.Add(new Tuple("build.js", false)); + list.Add(new Tuple("editorconfig", false)); + list.Add(new Tuple("gitattributes", false)); + + return list; + } + public async Task Get(GetDashboardPackage request) { var path = Path.Combine(_serverConfigurationManager.ApplicationPaths.ProgramDataPath, @@ -344,30 +376,12 @@ namespace MediaBrowser.WebDashboard.Api // Try to trim the output size a bit var bowerPath = Path.Combine(path, "bower_components"); - if (!string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)) - { - //var versionedBowerPath = Path.Combine(Path.GetDirectoryName(bowerPath), "bower_components" + _appHost.ApplicationVersion); - //Directory.Move(bowerPath, versionedBowerPath); - //bowerPath = versionedBowerPath; - } - - GetUndeployedExtensions().ForEach(i => DeleteFilesByExtension(bowerPath, i)); + GetDeployIgnoreExtensions().ForEach(i => DeleteFilesByExtension(bowerPath, i)); DeleteFilesByExtension(bowerPath, ".json", "strings\\"); - DeleteFilesByName(bowerPath, "copying", true); - DeleteFilesByName(bowerPath, "license", true); - DeleteFilesByName(bowerPath, "license-mit", true); - DeleteFilesByName(bowerPath, "gitignore"); - DeleteFilesByName(bowerPath, "npmignore"); - DeleteFilesByName(bowerPath, "jshintrc"); - DeleteFilesByName(bowerPath, "gruntfile"); - DeleteFilesByName(bowerPath, "bowerrc"); - DeleteFilesByName(bowerPath, "jscsrc"); - DeleteFilesByName(bowerPath, "hero.svg"); - DeleteFilesByName(bowerPath, "travis.yml"); - DeleteFilesByName(bowerPath, "build.js"); - DeleteFilesByName(bowerPath, "editorconfig"); - DeleteFilesByName(bowerPath, "gitattributes"); + + GetDeployIgnoreFilenames().ForEach(i => DeleteFilesByName(bowerPath, i.Item1, i.Item2)); + DeleteFoldersByName(bowerPath, "demo"); DeleteFoldersByName(bowerPath, "test"); DeleteFoldersByName(bowerPath, "guides"); diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 54dd52fb7..b2eb34526 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -101,6 +101,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -185,6 +188,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -326,7 +332,7 @@ PreserveNewest - + PreserveNewest @@ -338,7 +344,7 @@ PreserveNewest - + PreserveNewest @@ -356,7 +362,7 @@ PreserveNewest - + PreserveNewest @@ -377,7 +383,7 @@ PreserveNewest - + PreserveNewest @@ -503,7 +509,7 @@ PreserveNewest - + PreserveNewest @@ -863,13 +869,13 @@ PreserveNewest - + PreserveNewest PreserveNewest - + PreserveNewest @@ -881,7 +887,7 @@ PreserveNewest - + PreserveNewest @@ -896,10 +902,10 @@ PreserveNewest - + PreserveNewest - + PreserveNewest @@ -1089,7 +1095,7 @@ PreserveNewest - + PreserveNewest @@ -1356,7 +1362,7 @@ - + PreserveNewest @@ -1429,7 +1435,7 @@ - + PreserveNewest @@ -1441,7 +1447,7 @@ PreserveNewest - + PreserveNewest diff --git a/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs index 7523ce6bf..6380b9f53 100644 --- a/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs @@ -118,7 +118,9 @@ namespace MediaBrowser.XbmcMetadata.Savers "airsbefore_season", "DVD_episodenumber", "DVD_season", - "absolute_number" + "absolute_number", + "displayseason", + "displayepisode" }; return list; -- cgit v1.2.3