Merge pull request #1856 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-06-16 14:16:31 -04:00 committed by GitHub
commit 921bd80474
5 changed files with 572 additions and 2935 deletions

File diff suppressed because it is too large Load Diff

View File

@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Mac
var fileSystem = new ManagedFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")), false, true); var fileSystem = new ManagedFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")), false, true);
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
var nativeApp = new NativeApp(); var nativeApp = new NativeApp(logManager.GetLogger("App"));
AppHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "Emby.Server.Mac.pkg", nativeApp); AppHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "Emby.Server.Mac.pkg", nativeApp);

View File

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using MediaBrowser.Controller.Power; using MediaBrowser.Controller.Power;
using MediaBrowser.Server.Implementations.Persistence;
using MediaBrowser.Server.Startup.Common.FFMpeg; using MediaBrowser.Server.Startup.Common.FFMpeg;
using System.Diagnostics; using System.Diagnostics;
@ -14,6 +15,13 @@ namespace MediaBrowser.Server.Mac
{ {
public abstract class BaseMonoApp : INativeApp public abstract class BaseMonoApp : INativeApp
{ {
protected ILogger Logger { get; private set; }
protected BaseMonoApp(ILogger logger)
{
Logger = logger;
}
/// <summary> /// <summary>
/// Shutdowns this instance. /// Shutdowns this instance.
/// </summary> /// </summary>
@ -39,6 +47,21 @@ namespace MediaBrowser.Server.Mac
} }
} }
public void PreventSystemStandby()
{
}
public void AllowSystemStandby()
{
}
public IDbConnector GetDbConnector()
{
return new DbConnector(Logger);
}
public virtual bool SupportsLibraryMonitor public virtual bool SupportsLibraryMonitor
{ {
get get
@ -64,11 +87,6 @@ namespace MediaBrowser.Server.Mac
get { return false; } get { return false; }
} }
public void PreventSystemStandby()
{
}
public List<Assembly> GetAssembliesWithParts() public List<Assembly> GetAssembliesWithParts()
{ {
var list = new List<Assembly>(); var list = new List<Assembly>();

View File

@ -1,5 +1,6 @@
using System; using System;
using MediaBrowser.Server.Startup.Common; using MediaBrowser.Server.Startup.Common;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Server.Mac namespace MediaBrowser.Server.Mac
{ {
@ -8,6 +9,11 @@ namespace MediaBrowser.Server.Mac
/// </summary> /// </summary>
public class NativeApp : BaseMonoApp public class NativeApp : BaseMonoApp
{ {
public NativeApp(ILogger logger)
: base(logger)
{
}
/// <summary> /// <summary>
/// Shutdowns this instance. /// Shutdowns this instance.
/// </summary> /// </summary>

View File

@ -0,0 +1,62 @@
using System;
using System.Data;
using System.Data.SQLite;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Implementations.Persistence;
namespace MediaBrowser.Server.Mac
{
/// <summary>
/// Class SQLiteExtensions
/// </summary>
static class SqliteExtensions
{
/// <summary>
/// Connects to db.
/// </summary>
/// <param name="dbPath">The db path.</param>
/// <param name="logger">The logger.</param>
/// <returns>Task{IDbConnection}.</returns>
/// <exception cref="System.ArgumentNullException">dbPath</exception>
public static async Task<IDbConnection> ConnectToDb(string dbPath, ILogger logger)
{
if (string.IsNullOrEmpty(dbPath))
{
throw new ArgumentNullException("dbPath");
}
logger.Info("Sqlite {0} opening {1}", SQLiteConnection.SQLiteVersion, dbPath);
var connectionstr = new SQLiteConnectionStringBuilder
{
PageSize = 4096,
CacheSize = 2000,
SyncMode = SynchronizationModes.Full,
DataSource = dbPath,
JournalMode = SQLiteJournalModeEnum.Wal
};
var connection = new SQLiteConnection(connectionstr.ConnectionString);
await connection.OpenAsync().ConfigureAwait(false);
return connection;
}
}
public class DbConnector : IDbConnector
{
private readonly ILogger _logger;
public DbConnector(ILogger logger)
{
_logger = logger;
}
public Task<IDbConnection> Connect(string dbPath)
{
return SqliteExtensions.ConnectToDb(dbPath, _logger);
}
}
}