Release5767.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using MediaBrowser.Common.ScheduledTasks;
  5. using MediaBrowser.Controller.Configuration;
  6. using MediaBrowser.Server.Implementations.LiveTv;
  7. using MediaBrowser.Server.Implementations.Persistence;
  8. using MediaBrowser.Server.Implementations.ScheduledTasks;
  9. namespace MediaBrowser.Server.Startup.Common.Migrations
  10. {
  11. public class Release5767 : IVersionMigration
  12. {
  13. private readonly IServerConfigurationManager _config;
  14. private readonly ITaskManager _taskManager;
  15. public Release5767(IServerConfigurationManager config, ITaskManager taskManager)
  16. {
  17. _config = config;
  18. _taskManager = taskManager;
  19. }
  20. public async void Run()
  21. {
  22. var name = "5767.1";
  23. if (_config.Configuration.Migrations.Contains(name, StringComparer.OrdinalIgnoreCase))
  24. {
  25. return;
  26. }
  27. Task.Run(async () =>
  28. {
  29. await Task.Delay(3000).ConfigureAwait(false);
  30. _taskManager.QueueScheduledTask<RefreshChannelsScheduledTask>();
  31. _taskManager.QueueScheduledTask<CleanDatabaseScheduledTask>();
  32. _taskManager.QueueScheduledTask<RefreshMediaLibraryTask>();
  33. });
  34. // Wait a few minutes before marking this as done. Make sure the server doesn't get restarted.
  35. await Task.Delay(300000).ConfigureAwait(false);
  36. var list = _config.Configuration.Migrations.ToList();
  37. list.Add(name);
  38. _config.Configuration.Migrations = list.ToArray();
  39. _config.SaveConfiguration();
  40. }
  41. }
  42. }