The Free Software Media System - Server Backend & API
fixed plugin assembly downloads as well as debug/release detection with nuget assemblies
LukePulverenti364fbb9e0c75
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.csindex f38013d00c..e7abad1a43 100644--- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs+++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs@@ -12,6 +12,20 @@ namespace MediaBrowser.Common.Implementations/// </summary>public abstract class BaseApplicationPaths : IApplicationPaths{+ /// <summary>+ /// The _use debug path+ /// </summary>+ private bool _useDebugPath;++ /// <summary>+ /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.+ /// </summary>+ /// <param name="useDebugPath">if set to <c>true</c> [use debug paths].</param>+ protected BaseApplicationPaths(bool useDebugPath)+ {+ _useDebugPath = useDebugPath;+ }+/// <summary>/// The _program data path/// </summary>@@ -272,14 +286,9 @@ namespace MediaBrowser.Common.Implementations/// Gets the path to the application's ProgramDataFolder/// </summary>/// <returns>System.String.</returns>- public static string GetProgramDataPath()+ private string GetProgramDataPath(){-#if DEBUG- string programDataPath = ConfigurationManager.AppSettings["DebugProgramDataPath"];--#else- string programDataPath = Path.Combine(ConfigurationManager.AppSettings["ReleaseProgramDataPath"], ConfigurationManager.AppSettings["ProgramDataFolderName"]);-#endif+ var programDataPath = _useDebugPath ? ConfigurationManager.AppSettings["DebugProgramDataPath"] : Path.Combine(ConfigurationManager.AppSettings["ReleaseProgramDataPath"], ConfigurationManager.AppSettings["ProgramDataFolderName"]);programDataPath = programDataPath.Replace("%CommonApplicationData%", Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.csindex 7a14923593..eb5381e206 100644--- a/MediaBrowser.Common/Kernel/BaseKernel.cs+++ b/MediaBrowser.Common/Kernel/BaseKernel.cs@@ -312,8 +312,6 @@ namespace MediaBrowser.Common.Kernel// Set these to null so that they can be lazy loaded againConfiguration = null;- ReloadLogger();-Logger.Info("Version {0} initializing", ApplicationVersion);await OnConfigurationLoaded().ConfigureAwait(false);diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csprojindex dd73e8877e..bc3678a5e2 100644--- a/MediaBrowser.Common/MediaBrowser.Common.csproj+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj@@ -107,6 +107,7 @@<Compile Include="Net\IWebSocket.cs" /><Compile Include="Net\IWebSocketServer.cs" /><Compile Include="Net\MimeTypes.cs" />+ <Compile Include="Net\StreamWriter.cs" /><Compile Include="Net\UdpMessageReceivedEventArgs.cs" /><Compile Include="Net\WebSocketConnectEventArgs.cs" /><Compile Include="Net\WebSocketConnection.cs" />diff --git a/MediaBrowser.Common/Net/BaseRestService.cs b/MediaBrowser.Common/Net/BaseRestService.csindex 59818a9325..a7e95fca2f 100644--- a/MediaBrowser.Common/Net/BaseRestService.cs+++ b/MediaBrowser.Common/Net/BaseRestService.cs@@ -241,6 +241,10 @@ namespace MediaBrowser.Common.Net{return false;}+ if (contentType.StartsWith("application/", StringComparison.OrdinalIgnoreCase))+ {+ return false;+ }return true;}@@ -257,7 +261,10 @@ namespace MediaBrowser.Common.Netif (!compress || string.IsNullOrEmpty(RequestContext.CompressionType)){Response.ContentType = contentType;- return await factoryFn().ConfigureAwait(false);++ var stream = await factoryFn().ConfigureAwait(false);++ return new StreamWriter(stream);}string content;diff --git a/MediaBrowser.Common/Net/MimeTypes.cs b/MediaBrowser.Common/Net/MimeTypes.csindex b9d0347d7e..7bd01bf6d7 100644--- a/MediaBrowser.Common/Net/MimeTypes.cs+++ b/MediaBrowser.Common/Net/MimeTypes.cs@@ -173,7 +173,7 @@ namespace MediaBrowser.Common.Net// Miscif (ext.Equals(".dll", StringComparison.OrdinalIgnoreCase)){- return "application/x-msdownload";+ return "application/octet-stream";}// Webdiff --git a/MediaBrowser.Common/Net/StreamWriter.cs b/MediaBrowser.Common/Net/StreamWriter.csnew file mode 100644index 0000000000..220c52578e--- /dev/null+++ b/MediaBrowser.Common/Net/StreamWriter.cs@@ -0,0 +1,48 @@+using ServiceStack.Service;+using System.IO;+using System.Threading.Tasks;++namespace MediaBrowser.Common.Net+{+ /// <summary>+ /// Class StreamWriter+ /// </summary>+ public class StreamWriter : IStreamWriter+ {+ /// <summary>+ /// Gets or sets the source stream.+ /// </summary>+ /// <value>The source stream.</value>+ public Stream SourceStream { get; set; }++ /// <summary>+ /// Initializes a new instance of the <see cref="StreamWriter" /> class.+ /// </summary>+ /// <param name="source">The source.</param>+ public StreamWriter(Stream source)+ {+ SourceStream = source;+ }++ /// <summary>+ /// Writes to.+ /// </summary>+ /// <param name="responseStream">The response stream.</param>+ public void WriteTo(Stream responseStream)+ {+ var task = WriteToAsync(responseStream);++ Task.WaitAll(task);+ }++ /// <summary>+ /// Writes to async.+ /// </summary>+ /// <param name="responseStream">The response stream.</param>+ /// <returns>Task.</returns>+ private Task WriteToAsync(Stream responseStream)+ {+ return SourceStream.CopyToAsync(responseStream);+ }+ }+}diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.csindex e473808f5c..a5e5b39c44 100644--- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs+++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs@@ -9,6 +9,20 @@ namespace MediaBrowser.Server.Implementations/// </summary>public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths{+#if (DEBUG)+ /// <summary>+ /// Initializes a new instance of the <see cref="ServerApplicationPaths" /> class.+ /// </summary>+ public ServerApplicationPaths()+ : base(true)+ {+ }+#elif (RELEASE)+ public ServerApplicationPaths()+ : base(false)+ {+ }+#endif/// <summary>/// The _root folder path/// </summary>diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.csindex 88eb1c7e11..5a98e7d93d 100644--- a/MediaBrowser.ServerApplication/ApplicationHost.cs+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs@@ -119,6 +119,7 @@ namespace MediaBrowser.ServerApplication_taskManager = new TaskManager(_applicationPaths, _jsonSerializer, Logger);Kernel = new Kernel(this, _applicationPaths, _xmlSerializer, _taskManager, Logger);+ ReloadLogger();RegisterResources();@@ -333,7 +334,7 @@ namespace MediaBrowser.ServerApplication/// <exception cref="System.NotImplementedException"></exception>public void ReloadLogger(){- LogFilePath = Path.Combine(Kernel.ApplicationPaths.LogDirectoryPath, "Server-" + DateTime.Now.Ticks + ".log");+ LogFilePath = Path.Combine(_applicationPaths.LogDirectoryPath, "Server-" + DateTime.Now.Ticks + ".log");NlogManager.AddFileTarget(LogFilePath, Kernel.Configuration.EnableDebugLevelLogging);}