mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-10-02 08:47:59 +02:00
moved rootdir to eloquera
This commit is contained in:
@@ -2,27 +2,52 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Eloquera.Client;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class EloqueraDbFactory
|
||||
{
|
||||
public EloqueraDb CreateMemoryDb()
|
||||
private readonly EnvironmentProvider _environmentProvider;
|
||||
|
||||
private readonly string dllPath;
|
||||
|
||||
public EloqueraDbFactory(EnvironmentProvider environmentProvider)
|
||||
{
|
||||
return InternalCreate("server=(local);password=;options=inmemory;",Guid.NewGuid().ToString());
|
||||
_environmentProvider = environmentProvider;
|
||||
dllPath = _environmentProvider.GetWebBinPath();// this is the path where Eloquera dlls live.
|
||||
}
|
||||
|
||||
public EloqueraDb Create(string dbPath)
|
||||
public EloqueraDb CreateMemoryDb()
|
||||
{
|
||||
var file = new FileInfo(dbPath).Name;
|
||||
return InternalCreate(string.Format("server=(local);database={0};usedatapath={1};password=;", file, dbPath),file);
|
||||
return InternalCreate("server=(local);password=;options=inmemory;uselocalpath=" + dllPath, Guid.NewGuid().ToString());
|
||||
}
|
||||
|
||||
public EloqueraDb Create(string dbPath = null)
|
||||
{
|
||||
if (dbPath == null)
|
||||
{
|
||||
dbPath = _environmentProvider.GetElqMainDbPath();
|
||||
}
|
||||
|
||||
var file = new FileInfo(dbPath);
|
||||
|
||||
return InternalCreate(string.Format("server=(local);password=;usedatapath={0};uselocalpath={1}", file.Directory.FullName, dllPath), file.Name);
|
||||
}
|
||||
|
||||
private EloqueraDb InternalCreate(string connectionString, string databaseName)
|
||||
{
|
||||
var db = new DB(connectionString);
|
||||
db.CreateDatabase(databaseName);
|
||||
db.OpenDatabase(databaseName);
|
||||
try
|
||||
{
|
||||
db.OpenDatabase(databaseName);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
db.CreateDatabase(databaseName);
|
||||
db.OpenDatabase(databaseName);
|
||||
}
|
||||
|
||||
return new EloqueraDb(db);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user