Skip to content

Commit

Permalink
Merge pull request jellyfin#11100 from crobibero/plugin-repo-10.9
Browse files Browse the repository at this point in the history
Add migration for new plugin repo
  • Loading branch information
joshuaboniface committed Mar 3, 2024
2 parents 6e5ec99 + afacd8d commit 83d2bc3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Jellyfin.Server/Migrations/MigrationRunner.cs
Expand Up @@ -43,7 +43,8 @@ public sealed class MigrationRunner
typeof(Routines.MigrateAuthenticationDb),
typeof(Routines.FixPlaylistOwner),
typeof(Routines.MigrateRatingLevels),
typeof(Routines.AddDefaultCastReceivers)
typeof(Routines.AddDefaultCastReceivers),
typeof(Routines.UpdateDefaultPluginRepository)
};

/// <summary>
Expand Down
@@ -0,0 +1,52 @@
using System;
using MediaBrowser.Controller.Configuration;

namespace Jellyfin.Server.Migrations.Routines;

/// <summary>
/// Migration to update the default Jellyfin plugin repository.
/// </summary>
public class UpdateDefaultPluginRepository : IMigrationRoutine
{
private const string NewRepositoryUrl = "https://repo.jellyfin.org/files/plugin/manifest.json";
private const string OldRepositoryUrl = "https://repo.jellyfin.org/releases/plugin/manifest-stable.json";

private readonly IServerConfigurationManager _serverConfigurationManager;

/// <summary>
/// Initializes a new instance of the <see cref="UpdateDefaultPluginRepository"/> class.
/// </summary>
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
public UpdateDefaultPluginRepository(IServerConfigurationManager serverConfigurationManager)
{
_serverConfigurationManager = serverConfigurationManager;
}

/// <inheritdoc />
public Guid Id => new("852816E0-2712-49A9-9240-C6FC5FCAD1A8");

/// <inheritdoc />
public string Name => "UpdateDefaultPluginRepository10.9";

/// <inheritdoc />
public bool PerformOnNewInstall => true;

/// <inheritdoc />
public void Perform()
{
var updated = false;
foreach (var repo in _serverConfigurationManager.Configuration.PluginRepositories)
{
if (string.Equals(repo.Url, OldRepositoryUrl, StringComparison.OrdinalIgnoreCase))
{
repo.Url = NewRepositoryUrl;
updated = true;
}
}

if (updated)
{
_serverConfigurationManager.SaveConfiguration();
}
}
}
Expand Up @@ -50,7 +50,7 @@ public async Task GetPackages_Valid_Success()
{
PackageInfo[] packages = await _installationManager.GetPackages(
"Jellyfin Stable",
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
"https://repo.jellyfin.org/files/plugin/manifest.json",
false);

Assert.Equal(25, packages.Length);
Expand All @@ -61,7 +61,7 @@ public async Task FilterPackages_NameOnly_Success()
{
PackageInfo[] packages = await _installationManager.GetPackages(
"Jellyfin Stable",
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
"https://repo.jellyfin.org/files/plugin/manifest.json",
false);

packages = _installationManager.FilterPackages(packages, "Anime").ToArray();
Expand All @@ -73,7 +73,7 @@ public async Task FilterPackages_GuidOnly_Success()
{
PackageInfo[] packages = await _installationManager.GetPackages(
"Jellyfin Stable",
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
"https://repo.jellyfin.org/files/plugin/manifest.json",
false);

packages = _installationManager.FilterPackages(packages, id: new Guid("a4df60c5-6ab4-412a-8f79-2cab93fb2bc5")).ToArray();
Expand Down

0 comments on commit 83d2bc3

Please sign in to comment.