2015-10-29 14:28:05 +01:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MediaBrowser.Common.ScheduledTasks;
|
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using MediaBrowser.Server.Implementations.Persistence;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Startup.Common.Migrations
|
|
|
|
|
{
|
|
|
|
|
public class DbMigration : IVersionMigration
|
|
|
|
|
{
|
|
|
|
|
private readonly IServerConfigurationManager _config;
|
|
|
|
|
private readonly ITaskManager _taskManager;
|
|
|
|
|
|
|
|
|
|
public DbMigration(IServerConfigurationManager config, ITaskManager taskManager)
|
|
|
|
|
{
|
|
|
|
|
_config = config;
|
|
|
|
|
_taskManager = taskManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Run()
|
|
|
|
|
{
|
2016-02-04 19:04:04 +01:00
|
|
|
|
if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion &&
|
|
|
|
|
_config.Configuration.IsStartupWizardCompleted)
|
2015-10-29 14:28:05 +01:00
|
|
|
|
{
|
2016-02-03 21:52:45 +01:00
|
|
|
|
_taskManager.SuspendTriggers = true;
|
2016-02-01 20:54:49 +01:00
|
|
|
|
CleanDatabaseScheduledTask.EnableUnavailableMessage = true;
|
|
|
|
|
|
2015-11-02 18:25:01 +01:00
|
|
|
|
Task.Run(async () =>
|
|
|
|
|
{
|
2016-02-03 23:42:33 +01:00
|
|
|
|
await Task.Delay(100).ConfigureAwait(false);
|
2015-10-29 14:28:05 +01:00
|
|
|
|
|
2016-02-03 21:52:45 +01:00
|
|
|
|
_taskManager.Execute<CleanDatabaseScheduledTask>();
|
2015-11-02 18:25:01 +01:00
|
|
|
|
});
|
|
|
|
|
}
|
2015-10-29 14:28:05 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|