mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Autofac registrations are not singleton anymore.
This commit is contained in:
parent
3cdff3bb71
commit
f2886d89de
5 changed files with 34 additions and 23 deletions
|
@ -1,4 +1,6 @@
|
|||
using System.Reflection;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using FluentMigrator.Runner;
|
||||
using FluentMigrator.Runner.Initialization;
|
||||
using FluentMigrator.Runner.Processors.Sqlite;
|
||||
|
@ -14,6 +16,8 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||
{
|
||||
private readonly IAnnouncer _announcer;
|
||||
|
||||
private static readonly HashSet<string> MigrationCache = new HashSet<string>();
|
||||
|
||||
public MigrationController(IAnnouncer announcer)
|
||||
{
|
||||
_announcer = announcer;
|
||||
|
@ -21,19 +25,26 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||
|
||||
public void MigrateToLatest(string connectionString, MigrationType migrationType)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
var migrationContext = new RunnerContext(_announcer)
|
||||
lock (MigrationCache)
|
||||
{
|
||||
Namespace = "NzbDrone.Core.Datastore.Migration",
|
||||
ApplicationContext = migrationType
|
||||
};
|
||||
if (MigrationCache.Contains(connectionString.ToLower())) return;
|
||||
|
||||
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
|
||||
var factory = new SqliteProcessorFactory();
|
||||
var processor = factory.Create(connectionString, _announcer, options);
|
||||
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
||||
runner.MigrateUp(true);
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
var migrationContext = new RunnerContext(_announcer)
|
||||
{
|
||||
Namespace = "NzbDrone.Core.Datastore.Migration",
|
||||
ApplicationContext = migrationType
|
||||
};
|
||||
|
||||
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
|
||||
var factory = new SqliteProcessorFactory();
|
||||
var processor = factory.Create(connectionString, _announcer, options);
|
||||
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
||||
runner.MigrateUp(true);
|
||||
|
||||
MigrationCache.Add(connectionString.ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue