mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-28 04:55:11 +01:00
update db queries
This commit is contained in:
@@ -363,7 +363,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||
{
|
||||
var migrations = new List<IVersionMigration>
|
||||
{
|
||||
new Release5767(ServerConfigurationManager, TaskManager)
|
||||
new DbMigration(ServerConfigurationManager, TaskManager)
|
||||
};
|
||||
|
||||
foreach (var task in migrations)
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
<Compile Include="INativeApp.cs" />
|
||||
<Compile Include="MbLinkShortcutHandler.cs" />
|
||||
<Compile Include="Migrations\IVersionMigration.cs" />
|
||||
<Compile Include="Migrations\Release5767.cs" />
|
||||
<Compile Include="Migrations\DbMigration.cs" />
|
||||
<Compile Include="Migrations\RenameXmlOptions.cs" />
|
||||
<Compile Include="NativeEnvironment.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
34
MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
Normal file
34
MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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()
|
||||
{
|
||||
if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
|
||||
_taskManager.QueueScheduledTask<CleanDatabaseScheduledTask>();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Server.Implementations.LiveTv;
|
||||
using MediaBrowser.Server.Implementations.Persistence;
|
||||
using MediaBrowser.Server.Implementations.ScheduledTasks;
|
||||
|
||||
namespace MediaBrowser.Server.Startup.Common.Migrations
|
||||
{
|
||||
public class Release5767 : IVersionMigration
|
||||
{
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ITaskManager _taskManager;
|
||||
|
||||
public Release5767(IServerConfigurationManager config, ITaskManager taskManager)
|
||||
{
|
||||
_config = config;
|
||||
_taskManager = taskManager;
|
||||
}
|
||||
|
||||
public async void Run()
|
||||
{
|
||||
var name = "5767.1";
|
||||
|
||||
if (_config.Configuration.Migrations.Contains(name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(3000).ConfigureAwait(false);
|
||||
|
||||
_taskManager.QueueScheduledTask<CleanDatabaseScheduledTask>();
|
||||
});
|
||||
|
||||
// Wait a few minutes before marking this as done. Make sure the server doesn't get restarted.
|
||||
await Task.Delay(300000).ConfigureAwait(false);
|
||||
|
||||
var list = _config.Configuration.Migrations.ToList();
|
||||
list.Add(name);
|
||||
_config.Configuration.Migrations = list.ToArray();
|
||||
_config.SaveConfiguration();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user