ReaddDefaultPluginRepository.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using MediaBrowser.Controller.Configuration;
  3. using MediaBrowser.Model.Updates;
  4. namespace Jellyfin.Server.Migrations.Routines
  5. {
  6. /// <summary>
  7. /// Migration to initialize system configuration with the default plugin repository.
  8. /// </summary>
  9. [JellyfinMigration("2025-04-20T11:00:00", nameof(ReaddDefaultPluginRepository), "5F86E7F6-D966-4C77-849D-7A7B40B68C4E", RunMigrationOnSetup = true)]
  10. #pragma warning disable CS0618 // Type or member is obsolete
  11. public class ReaddDefaultPluginRepository : IMigrationRoutine
  12. #pragma warning restore CS0618 // Type or member is obsolete
  13. {
  14. private readonly IServerConfigurationManager _serverConfigurationManager;
  15. private readonly RepositoryInfo _defaultRepositoryInfo = new RepositoryInfo
  16. {
  17. Name = "Jellyfin Stable",
  18. Url = "https://repo.jellyfin.org/releases/plugin/manifest-stable.json"
  19. };
  20. /// <summary>
  21. /// Initializes a new instance of the <see cref="ReaddDefaultPluginRepository"/> class.
  22. /// </summary>
  23. /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
  24. public ReaddDefaultPluginRepository(IServerConfigurationManager serverConfigurationManager)
  25. {
  26. _serverConfigurationManager = serverConfigurationManager;
  27. }
  28. /// <inheritdoc/>
  29. public void Perform()
  30. {
  31. // Only add if repository list is empty
  32. if (_serverConfigurationManager.Configuration.PluginRepositories.Length == 0)
  33. {
  34. _serverConfigurationManager.Configuration.PluginRepositories = new[] { _defaultRepositoryInfo };
  35. _serverConfigurationManager.SaveConfiguration();
  36. }
  37. }
  38. }
  39. }