jellyfin-server/Emby.Server.Implementations/Migrations/LibraryScanMigration.cs

50 lines
1.6 KiB
C#
Raw Normal View History

2016-12-13 18:41:36 +00:00
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Updates;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Updates;
using System.Linq;
namespace Emby.Server.Implementations.Migrations
{
public class LibraryScanMigration : IVersionMigration
{
private readonly IServerConfigurationManager _config;
private readonly ITaskManager _taskManager;
public LibraryScanMigration(IServerConfigurationManager config, ITaskManager taskManager)
{
_config = config;
_taskManager = taskManager;
}
2017-05-26 06:48:54 +00:00
public Task Run()
2016-12-13 18:41:36 +00:00
{
var name = "LibraryScan6";
if (!_config.Configuration.Migrations.Contains(name, StringComparer.OrdinalIgnoreCase))
{
Task.Run(() =>
{
_taskManager.QueueScheduledTask(_taskManager.ScheduledTasks.Select(i => i.ScheduledTask)
.First(i => string.Equals(i.Key, "RefreshLibrary", StringComparison.OrdinalIgnoreCase)));
2016-12-13 18:41:36 +00:00
});
var list = _config.Configuration.Migrations.ToList();
list.Add(name);
_config.Configuration.Migrations = list.ToArray();
_config.SaveConfiguration();
}
2017-05-26 06:48:54 +00:00
return Task.FromResult(true);
2016-12-13 18:41:36 +00:00
}
}
}