Merge branch 'master' into dev
This commit is contained in:
commit
fd3ff632d4
File diff suppressed because it is too large
Load Diff
|
@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Mac
|
|||
var fileSystem = new ManagedFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")), false, true);
|
||||
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);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using MediaBrowser.Controller.Power;
|
||||
using MediaBrowser.Server.Implementations.Persistence;
|
||||
using MediaBrowser.Server.Startup.Common.FFMpeg;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
@ -14,6 +15,13 @@ namespace MediaBrowser.Server.Mac
|
|||
{
|
||||
public abstract class BaseMonoApp : INativeApp
|
||||
{
|
||||
protected ILogger Logger { get; private set; }
|
||||
|
||||
protected BaseMonoApp(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shutdowns this instance.
|
||||
/// </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
|
||||
{
|
||||
get
|
||||
|
@ -64,11 +87,6 @@ namespace MediaBrowser.Server.Mac
|
|||
get { return false; }
|
||||
}
|
||||
|
||||
public void PreventSystemStandby()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<Assembly> GetAssembliesWithParts()
|
||||
{
|
||||
var list = new List<Assembly>();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using MediaBrowser.Server.Startup.Common;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Server.Mac
|
||||
{
|
||||
|
@ -8,7 +9,12 @@ namespace MediaBrowser.Server.Mac
|
|||
/// </summary>
|
||||
public class NativeApp : BaseMonoApp
|
||||
{
|
||||
/// <summary>
|
||||
public NativeApp(ILogger logger)
|
||||
: base(logger)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shutdowns this instance.
|
||||
/// </summary>
|
||||
public override void Shutdown()
|
||||
|
|
62
MediaBrowser.Server.Mac/Native/SqliteExtensions.cs
Normal file
62
MediaBrowser.Server.Mac/Native/SqliteExtensions.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user