mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-03 17:42:56 +00:00
WIP: Change pandocs download function to account for different cpu architectures
This commit is contained in:
parent
b60d23a91b
commit
331c6caf4b
@ -92,14 +92,35 @@ public static partial class Pandoc
|
|||||||
Directory.CreateDirectory(installDir);
|
Directory.CreateDirectory(installDir);
|
||||||
|
|
||||||
using var client = new HttpClient();
|
using var client = new HttpClient();
|
||||||
var response = await client.GetAsync(await GenerateUriAsync());
|
var uri = await GenerateUriAsync();
|
||||||
if (response.IsSuccessStatusCode)
|
|
||||||
|
var response = await client.GetAsync(uri);
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Error, $"Pandoc was not installed successfully, because the download archive was not found."));
|
||||||
|
LOG.LogError("Pandoc was not installed, the release archive was not found (Status Code {StatusCode}):\n{Uri}\n{Message}", response.StatusCode, uri, response.RequestMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var fileBytes = await response.Content.ReadAsByteArrayAsync();
|
var fileBytes = await response.Content.ReadAsByteArrayAsync();
|
||||||
|
|
||||||
|
if (uri.Contains(".zip"))
|
||||||
|
{
|
||||||
var tempZipPath = Path.Join(Path.GetTempPath(), "pandoc.zip");
|
var tempZipPath = Path.Join(Path.GetTempPath(), "pandoc.zip");
|
||||||
await File.WriteAllBytesAsync(tempZipPath, fileBytes);
|
await File.WriteAllBytesAsync(tempZipPath, fileBytes);
|
||||||
ZipFile.ExtractToDirectory(tempZipPath, installDir);
|
ZipFile.ExtractToDirectory(tempZipPath, installDir);
|
||||||
File.Delete(tempZipPath);
|
File.Delete(tempZipPath);
|
||||||
|
}
|
||||||
|
else if (uri.Contains(".tar.gz"))
|
||||||
|
{
|
||||||
|
Console.WriteLine("is zip");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Error, $"Pandoc was not installed successfully, because the download archive type is unknown."));
|
||||||
|
LOG.LogError("Pandoc was not installed, the download archive is unknown:\n {Uri}", uri);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var currentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
|
var currentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
|
||||||
var pandocDir = Path.Join(currentPath, "pandoc-3.6.4");
|
var pandocDir = Path.Join(currentPath, "pandoc-3.6.4");
|
||||||
@ -116,12 +137,8 @@ public static partial class Pandoc
|
|||||||
Console.WriteLine("Pandoc-Verzeichnis ist bereits im PATH.");
|
Console.WriteLine("Pandoc-Verzeichnis ist bereits im PATH.");
|
||||||
}
|
}
|
||||||
|
|
||||||
await MessageBus.INSTANCE.SendSuccess(new(Icons.Material.Filled.CheckCircle, $"Pandoc {MINIMUM_REQUIRED_VERSION.ToString()} was installed successfully."));
|
await MessageBus.INSTANCE.SendSuccess(new(Icons.Material.Filled.CheckCircle,
|
||||||
}
|
$"Pandoc {MINIMUM_REQUIRED_VERSION.ToString()} was installed successfully."));
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Fehler beim Herunterladen von Pandoc.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -129,6 +146,11 @@ public static partial class Pandoc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task ExtractZipAsync(string zipPath, string targetDir)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<string> FetchLatestVersionAsync() {
|
public static async Task<string> FetchLatestVersionAsync() {
|
||||||
using var client = new HttpClient();
|
using var client = new HttpClient();
|
||||||
var response = await client.GetAsync(LATEST_URL);
|
var response = await client.GetAsync(LATEST_URL);
|
||||||
|
Loading…
Reference in New Issue
Block a user