mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
This commit is contained in:
parent
693eceb80f
commit
7aa87d397e
@ -65,5 +65,17 @@ namespace BTCPayServer.Plugins
|
||||
var result = await httpClient.GetStringAsync($"api/v1/plugins{queryString}");
|
||||
return JsonConvert.DeserializeObject<PublishedVersion[]>(result, serializerSettings) ?? throw new InvalidOperationException();
|
||||
}
|
||||
public async Task<PublishedVersion> GetPlugin(string pluginSlug, string version)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await httpClient.GetStringAsync($"api/v1/plugins/{pluginSlug}/versions/{version}");
|
||||
return JsonConvert.DeserializeObject<PublishedVersion>(result, serializerSettings);
|
||||
}
|
||||
catch (HttpRequestException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,9 +72,11 @@ namespace BTCPayServer.Plugins
|
||||
var dest = _dataDirectories.Value.PluginDir;
|
||||
var filedest = Path.Join(dest, pluginIdentifier + ".btcpay");
|
||||
var filemanifestdest = Path.Join(dest, pluginIdentifier + ".json");
|
||||
var pluginSelector = $"[{Uri.EscapeDataString(pluginIdentifier)}]";
|
||||
version = Uri.EscapeDataString(version);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filedest));
|
||||
var url = $"api/v1/plugins/[{Uri.EscapeDataString(pluginIdentifier)}]/versions/{Uri.EscapeDataString(version)}/download";
|
||||
var manifest = (await _pluginBuilderClient.GetPublishedVersions(null, true)).Select(v => v.ManifestInfo.ToObject<AvailablePlugin>()).FirstOrDefault(p => p.Identifier == pluginIdentifier);
|
||||
var url = $"api/v1/plugins/{pluginSelector}/versions/{version}/download";
|
||||
var manifest = (await _pluginBuilderClient.GetPlugin(pluginSelector, version))?.ManifestInfo?.ToObject<AvailablePlugin>();
|
||||
await File.WriteAllTextAsync(filemanifestdest, JsonConvert.SerializeObject(manifest, Formatting.Indented));
|
||||
using var resp2 = await _pluginBuilderClient.HttpClient.GetAsync(url);
|
||||
await using var fs = new FileStream(filedest, FileMode.Create, FileAccess.ReadWrite);
|
||||
|
Loading…
Reference in New Issue
Block a user