Change plugin update IO logic
This commit is contained in:
@@ -95,6 +95,10 @@ namespace Torch.API.WebAPI
|
||||
try
|
||||
{
|
||||
path = path ?? $"Plugins\\{item.Name}.zip";
|
||||
string relpath = Path.GetDirectoryName(path);
|
||||
|
||||
Directory.CreateDirectory(relpath);
|
||||
|
||||
var h = await _client.GetAsync(string.Format(PLUGIN_QUERY, item.ID));
|
||||
string res = await h.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<PluginFullItem>(res);
|
||||
@@ -110,7 +114,11 @@ namespace Torch.API.WebAPI
|
||||
return false;
|
||||
}
|
||||
var s = await _client.GetStreamAsync(version.URL);
|
||||
using (var f = new FileStream(path, FileMode.Create))
|
||||
|
||||
if(File.Exists(path))
|
||||
File.Delete(path);
|
||||
|
||||
using (var f = File.Create(path))
|
||||
{
|
||||
await s.CopyToAsync(f);
|
||||
await f.FlushAsync();
|
||||
|
@@ -23,8 +23,12 @@ namespace Torch
|
||||
/// <summary>
|
||||
/// A GitHub repository in the format of Author/Repository to retrieve plugin updates.
|
||||
/// </summary>
|
||||
[Obsolete("Updates no longer check git. Updates are hosted only on torchapi.net")]
|
||||
public string Repository { get; set; }
|
||||
|
||||
//xml tomfoolery
|
||||
public bool ShouldSerializeRepository() => false;
|
||||
|
||||
/// <summary>
|
||||
/// The plugin version. This must include a string in the format of #[.#[.#]] for update checking purposes.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user