Merge pull request #2298 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-11-20 19:58:37 -05:00 committed by GitHub
commit b91ebfae1b
13 changed files with 150 additions and 156 deletions

View File

@ -132,6 +132,8 @@ using SocketHttpListener.Primitives;
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions; using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
using Emby.Drawing; using Emby.Drawing;
using Emby.Server.Implementations.Migrations; using Emby.Server.Implementations.Migrations;
using MediaBrowser.Model.Diagnostics;
using Emby.Common.Implementations.Diagnostics;
namespace Emby.Server.Core namespace Emby.Server.Core
{ {
@ -1543,7 +1545,39 @@ namespace Emby.Server.Core
} }
} }
public abstract void LaunchUrl(string url); public void LaunchUrl(string url)
{
if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows)
{
throw new NotImplementedException();
}
var process = ProcessFactory.Create(new ProcessOptions {
FileName = url,
EnableRaisingEvents = true,
UseShellExecute = true,
ErrorDialog = false
});
process.Exited += ProcessExited;
try
{
process.Start();
}
catch (Exception ex)
{
Console.WriteLine("Error launching url: {0}", url);
Logger.ErrorException("Error launching url: {0}", ex, url);
throw;
}
}
private static void ProcessExited(object sender, EventArgs e)
{
((IProcess)sender).Dispose();
}
public void EnableLoopback(string appName) public void EnableLoopback(string appName)
{ {

View File

@ -12,12 +12,22 @@ namespace Emby.Server.Implementations.Data
public abstract class BaseSqliteRepository : IDisposable public abstract class BaseSqliteRepository : IDisposable
{ {
protected string DbFilePath { get; set; } protected string DbFilePath { get; set; }
protected ReaderWriterLockSlim WriteLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); protected ReaderWriterLockSlim WriteLock;
protected ILogger Logger { get; private set; } protected ILogger Logger { get; private set; }
protected BaseSqliteRepository(ILogger logger) protected BaseSqliteRepository(ILogger logger)
{ {
Logger = logger; Logger = logger;
WriteLock = AllowLockRecursion ?
new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion) :
new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
}
protected virtual bool AllowLockRecursion
{
get { return false; }
} }
protected virtual bool EnableConnectionPooling protected virtual bool EnableConnectionPooling
@ -33,8 +43,17 @@ namespace Emby.Server.Implementations.Data
//CheckOk(rc); //CheckOk(rc);
} }
private static bool _versionLogged;
protected virtual SQLiteDatabaseConnection CreateConnection(bool isReadOnly = false) protected virtual SQLiteDatabaseConnection CreateConnection(bool isReadOnly = false)
{ {
if (!_versionLogged)
{
_versionLogged = true;
Logger.Info("Sqlite version: " + SQLite3.Version);
Logger.Info("Sqlite compiler options: " + string.Join(",", SQLite3.CompilerOptions.ToArray()));
}
ConnectionFlags connectionFlags; ConnectionFlags connectionFlags;
//isReadOnly = false; //isReadOnly = false;
@ -77,7 +96,7 @@ namespace Emby.Server.Implementations.Data
var cacheSize = CacheSize; var cacheSize = CacheSize;
if (cacheSize.HasValue) if (cacheSize.HasValue)
{ {
} }
if (EnableExclusiveMode) if (EnableExclusiveMode)
@ -197,11 +216,7 @@ namespace Emby.Server.Implementations.Data
return; return;
} }
connection.ExecuteAll(string.Join(";", new string[] connection.Execute("alter table " + table + " add column " + columnName + " " + type + " NULL");
{
"alter table " + table,
"add column " + columnName + " " + type + " NULL"
}));
} }
} }

View File

@ -95,6 +95,14 @@ namespace Emby.Server.Implementations.Data
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db"); DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
} }
protected override bool AllowLockRecursion
{
get
{
return true;
}
}
private const string ChaptersTableName = "Chapters2"; private const string ChaptersTableName = "Chapters2";
protected override int? CacheSize protected override int? CacheSize
@ -856,7 +864,7 @@ namespace Emby.Server.Implementations.Data
if (topParent != null) if (topParent != null)
{ {
//Logger.Debug("Item {0} has top parent {1}", item.Id, topParent.Id); //Logger.Debug("Item {0} has top parent {1}", item.Id, topParent.Id);
saveItemStatement.TryBind("@IsFolder", topParent.Id.ToString("N")); saveItemStatement.TryBind("@TopParentId", topParent.Id.ToString("N"));
} }
else else
{ {

View File

@ -89,7 +89,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{ {
Url = url, Url = url,
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
BufferContent = false BufferContent = false,
// Increase a little bit
TimeoutMs = 30000
}, "GET").ConfigureAwait(false)) }, "GET").ConfigureAwait(false))
{ {

View File

@ -147,7 +147,6 @@
</Compile> </Compile>
<Compile Include="Main.cs" /> <Compile Include="Main.cs" />
<Compile Include="MenuBarIcon.cs" /> <Compile Include="MenuBarIcon.cs" />
<Compile Include="Native\DbConnector.cs" />
<Compile Include="MacAppHost.cs" /> <Compile Include="MacAppHost.cs" />
<Compile Include="Native\MonoFileSystem.cs" /> <Compile Include="Native\MonoFileSystem.cs" />
<Compile Include="Native\PowerManagement.cs" /> <Compile Include="Native\PowerManagement.cs" />

View File

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Emby.Server.Core; using Emby.Server.Core;
using Emby.Server.Core.Data;
using Emby.Server.Implementations; using Emby.Server.Implementations;
using Emby.Server.Implementations.FFMpeg; using Emby.Server.Implementations.FFMpeg;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
@ -35,6 +34,14 @@ namespace MediaBrowser.Server.Mac
} }
} }
protected override bool SupportsDualModeSockets
{
get
{
return true;
}
}
protected override FFMpegInstallInfo GetFfmpegInstallInfo() protected override FFMpegInstallInfo GetFfmpegInstallInfo()
{ {
var info = new FFMpegInstallInfo(); var info = new FFMpegInstallInfo();
@ -95,11 +102,6 @@ namespace MediaBrowser.Server.Mac
throw new NotImplementedException(); throw new NotImplementedException();
} }
protected override IDbConnector GetDbConnector()
{
return new DbConnector(Logger);
}
protected override void ConfigureAutoRunInternal(bool autorun) protected override void ConfigureAutoRunInternal(bool autorun)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@ -1,24 +0,0 @@
using System;
using System.Data;
using System.Data.SQLite;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
using Emby.Server.Core.Data;
namespace MediaBrowser.Server.Mac
{
public class DbConnector : IDbConnector
{
private readonly ILogger _logger;
public DbConnector(ILogger logger)
{
_logger = logger;
}
public Task<IDbConnection> Connect(string dbPath, bool isReadOnly, bool enablePooling = false, int? cacheSize = null)
{
return SqliteExtensions.ConnectToDb(dbPath, isReadOnly, enablePooling, cacheSize, _logger);
}
}
}

View File

@ -126,11 +126,6 @@ namespace MediaBrowser.Server.Mono
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override void LaunchUrl(string url)
{
throw new NotImplementedException();
}
protected override void EnableLoopbackInternal(string appName) protected override void EnableLoopbackInternal(string appName)
{ {
} }

View File

@ -119,38 +119,6 @@ namespace MediaBrowser.ServerApplication
} }
} }
public override void LaunchUrl(string url)
{
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = url
},
EnableRaisingEvents = true,
};
process.Exited += ProcessExited;
try
{
process.Start();
}
catch (Exception ex)
{
Console.WriteLine("Error launching url: {0}", url);
Logger.ErrorException("Error launching url: {0}", ex, url);
throw;
}
}
private static void ProcessExited(object sender, EventArgs e)
{
((Process)sender).Dispose();
}
protected override void EnableLoopbackInternal(string appName) protected override void EnableLoopbackInternal(string appName)
{ {
LoopUtil.Run(appName); LoopUtil.Run(appName);

View File

@ -4,12 +4,11 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Emby.Server.Core; using Emby.Server.Core;
using Emby.Server.Core.Data; using Emby.Server.Implementations.FFMpeg;
using Emby.Server.Core.FFMpeg;
using Emby.Server.Data;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using Emby.Server.Implementations;
namespace Emby.Server namespace Emby.Server
{ {
@ -39,9 +38,37 @@ namespace Emby.Server
{ {
var info = new FFMpegInstallInfo(); var info = new FFMpegInstallInfo();
if (EnvironmentInfo.OperatingSystem == OperatingSystem.Windows)
{
info.FFMpegFilename = "ffmpeg.exe";
info.FFProbeFilename = "ffprobe.exe";
info.Version = "20160410";
info.ArchiveType = "7z";
info.DownloadUrls = GetDownloadUrls();
}
return info; return info;
} }
private string[] GetDownloadUrls()
{
switch (EnvironmentInfo.SystemArchitecture)
{
case Architecture.X64:
return new[]
{
"https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20160410-win64.7z"
};
case Architecture.X86:
return new[]
{
"https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20160410-win32.7z"
};
}
return new string[] { };
}
protected override List<Assembly> GetAssembliesWithPartsInternal() protected override List<Assembly> GetAssembliesWithPartsInternal()
{ {
var list = new List<Assembly>(); var list = new List<Assembly>();
@ -55,19 +82,10 @@ namespace Emby.Server
{ {
} }
protected override IDbConnector GetDbConnector()
{
return new DbConnector(Logger);
}
protected override void ConfigureAutoRunInternal(bool autorun) protected override void ConfigureAutoRunInternal(bool autorun)
{ {
} }
public override void LaunchUrl(string url)
{
}
protected override void EnableLoopbackInternal(string appName) protected override void EnableLoopbackInternal(string appName)
{ {
} }
@ -103,5 +121,13 @@ namespace Emby.Server
return Program.CanSelfUpdate; return Program.CanSelfUpdate;
} }
} }
protected override bool SupportsDualModeSockets
{
get
{
return true;
}
}
} }
} }

View File

@ -1,52 +0,0 @@
using System;
using System.Data;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
using Emby.Server.Core.Data;
using Microsoft.Data.Sqlite;
namespace Emby.Server.Data
{
public class DbConnector : IDbConnector
{
private readonly ILogger _logger;
public DbConnector(ILogger logger)
{
_logger = logger;
}
public async Task<IDbConnection> Connect(string dbPath, bool isReadOnly, bool enablePooling = false, int? cacheSize = null)
{
if (string.IsNullOrEmpty(dbPath))
{
throw new ArgumentNullException("dbPath");
}
//SQLiteConnection.SetMemoryStatus(false);
var connectionstr = new SqliteConnectionStringBuilder
{
//PageSize = 4096,
//CacheSize = cacheSize ?? 2000,
//SyncMode = SynchronizationModes.Normal,
DataSource = dbPath,
//JournalMode = SQLiteJournalModeEnum.Wal,
// This is causing crashing under linux
//Pooling = enablePooling && Environment.OSVersion.Platform == PlatformID.Win32NT,
//ReadOnly = isReadOnly,
Cache = enablePooling ? SqliteCacheMode.Default : SqliteCacheMode.Private,
Mode = isReadOnly ? SqliteOpenMode.ReadOnly : SqliteOpenMode.ReadWriteCreate
};
var connectionString = connectionstr.ConnectionString;
var connection = new SqliteConnection(connectionString);
await connection.OpenAsync().ConfigureAwait(false);
return connection;
}
}
}

View File

@ -15,10 +15,11 @@ using Emby.Common.Implementations.Logging;
using Emby.Common.Implementations.Networking; using Emby.Common.Implementations.Networking;
using Emby.Drawing; using Emby.Drawing;
using Emby.Server.Core; using Emby.Server.Core;
using Emby.Server.Core.Browser; using Emby.Server.Implementations.Browser;
using Emby.Server.Implementations.IO; using Emby.Server.Implementations.IO;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using Emby.Server.IO; using Emby.Server.IO;
using Emby.Server.Implementations;
namespace Emby.Server namespace Emby.Server
{ {
@ -38,19 +39,34 @@ namespace Emby.Server
/// </summary> /// </summary>
public static void Main(string[] args) public static void Main(string[] args)
{ {
var options = new StartupOptions(); var options = new StartupOptions(Environment.GetCommandLineArgs());
var environmentInfo = new EnvironmentInfo();
var currentProcess = Process.GetCurrentProcess();
var baseDirectory = System.AppContext.BaseDirectory; var baseDirectory = System.AppContext.BaseDirectory;
//var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86"); string archPath = baseDirectory;
if (environmentInfo.SystemArchitecture == MediaBrowser.Model.System.Architecture.X64)
{
archPath = Path.Combine(archPath, "x64");
}
else if (environmentInfo.SystemArchitecture == MediaBrowser.Model.System.Architecture.X86)
{
archPath = Path.Combine(archPath, "x86");
}
else
{
archPath = Path.Combine(archPath, "arm");
}
//Wand.SetMagickCoderModulePath(architecturePath); //Wand.SetMagickCoderModulePath(architecturePath);
//var success = SetDllDirectory(architecturePath); if (environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows)
{
SetDllDirectory(archPath);
}
var appPaths = CreateApplicationPaths(baseDirectory); var appPaths = CreateApplicationPaths(baseDirectory);
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3()); SetSqliteProvider();
var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
logManager.ReloadLogger(LogSeverity.Debug); logManager.ReloadLogger(LogSeverity.Debug);
@ -74,7 +90,12 @@ namespace Emby.Server
return; return;
} }
RunApplication(appPaths, logManager, options); RunApplication(appPaths, logManager, options, environmentInfo);
}
private static void SetSqliteProvider()
{
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
} }
/// <summary> /// <summary>
@ -170,7 +191,7 @@ namespace Emby.Server
/// <param name="appPaths">The app paths.</param> /// <param name="appPaths">The app paths.</param>
/// <param name="logManager">The log manager.</param> /// <param name="logManager">The log manager.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options) private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options, EnvironmentInfo environmentInfo)
{ {
var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true); var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true);
@ -184,7 +205,7 @@ namespace Emby.Server
fileSystem, fileSystem,
new PowerManagement(), new PowerManagement(),
"emby.windows.zip", "emby.windows.zip",
new EnvironmentInfo(), environmentInfo,
imageEncoder, imageEncoder,
new CoreSystemEvents(), new CoreSystemEvents(),
new MemoryStreamFactory(), new MemoryStreamFactory(),

View File

@ -9,18 +9,17 @@
"Emby.Server.Core": "1.0.0-*", "Emby.Server.Core": "1.0.0-*",
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"type": "platform", "type": "platform",
"version": "1.0.1" "version": "1.1.0"
}, },
"Mono.Nat": "1.0.0-*", "Mono.Nat": "1.0.0-*",
"Microsoft.Win32.Registry": "4.0.0", "Microsoft.Win32.Registry": "4.0.0",
"System.Runtime.Extensions": "4.1.0", "System.Runtime.Extensions": "4.1.0",
"System.Diagnostics.Process": "4.1.0", "System.Diagnostics.Process": "4.1.0",
"Microsoft.Data.SQLite": "1.1.0-preview1-final", "SQLitePCLRaw.provider.sqlite3.netstandard11": "1.1.1-pre20161109081005"
"SQLitePCLRaw.provider.sqlite3.netstandard11": "1.1.0"
}, },
"frameworks": { "frameworks": {
"netcoreapp1.0": { "netcoreapp1.1": {
"imports": "dnxcore50", "imports": "dnxcore50",
"dependencies": { "dependencies": {
"BDInfo": { "BDInfo": {