fixed plugin assembly downloads as well as debug/release detection with nuget assemblies
This commit is contained in:
parent
b075e0a5b9
commit
364fbb9e0c
|
@ -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));
|
||||
|
||||
|
|
|
@ -312,8 +312,6 @@ namespace MediaBrowser.Common.Kernel
|
|||
// Set these to null so that they can be lazy loaded again
|
||||
Configuration = null;
|
||||
|
||||
ReloadLogger();
|
||||
|
||||
Logger.Info("Version {0} initializing", ApplicationVersion);
|
||||
|
||||
await OnConfigurationLoaded().ConfigureAwait(false);
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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.Net
|
|||
if (!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;
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace MediaBrowser.Common.Net
|
|||
// Misc
|
||||
if (ext.Equals(".dll", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "application/x-msdownload";
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
// Web
|
||||
|
|
48
MediaBrowser.Common/Net/StreamWriter.cs
Normal file
48
MediaBrowser.Common/Net/StreamWriter.cs
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user