queries and restart fixes
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Torch.API.WebAPI
|
||||
public class PluginQuery
|
||||
{
|
||||
private const string ALL_QUERY = "https://torchapi.com/api/plugins/";
|
||||
private const string PLUGIN_QUERY = "https://torchapi.com/api/plugins/item/{0}/";
|
||||
private const string PLUGIN_QUERY = "https://torchapi.com/api/plugins/?guid={0}";
|
||||
private readonly HttpClient _client;
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
@@ -42,15 +42,15 @@ namespace Torch.API.WebAPI
|
||||
CancellationToken.None);
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPlugin(Guid guid, string path = null)
|
||||
public Task<bool> DownloadPlugin(Guid guid, string path = null)
|
||||
{
|
||||
return await DownloadPlugin(guid.ToString(), path);
|
||||
return DownloadPlugin(guid.ToString(), path);
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPlugin(string guid, string path = null)
|
||||
{
|
||||
var item = await QueryOne(guid);
|
||||
if (item == null) return false;
|
||||
if (item is null) return false;
|
||||
return await DownloadPlugin(item, path);
|
||||
}
|
||||
|
||||
@@ -59,14 +59,13 @@ namespace Torch.API.WebAPI
|
||||
try
|
||||
{
|
||||
path ??= Path.Combine(Directory.GetCurrentDirectory(), "Plugins", $"{item.Name}.zip");
|
||||
|
||||
var response = await QueryOne(item.Id);
|
||||
if (response.Versions.Length == 0)
|
||||
|
||||
if (item.Versions.Length == 0)
|
||||
{
|
||||
Log.Error($"Selected plugin {item.Name} does not have any versions to download!");
|
||||
return false;
|
||||
}
|
||||
var version = response.Versions.FirstOrDefault(v => v.Version == response.LatestVersion);
|
||||
var version = item.Versions.FirstOrDefault(v => v.Version == item.LatestVersion);
|
||||
if (version is null)
|
||||
{
|
||||
Log.Error($"Could not find latest version for selected plugin {item.Name}");
|
||||
|
Reference in New Issue
Block a user