aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/Migrations/Routines/UpdateDefaultPluginRepository.cs
blob: 7e8c8ac871c85fea141c118900caa4d7716b14e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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();
        }
    }
}