mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-07-10 04:21:49 +02:00
Better error handling for fetching models.txt, news, patrons
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Flowframes.OS
|
||||
public enum VersionCompareResult { Older, Newer, Equal };
|
||||
public static string latestVerUrl = "https://dl.nmkd.de/flowframes/exe/ver.ini";
|
||||
|
||||
public static string GetInstalledVerStr ()
|
||||
public static string GetInstalledVerStr()
|
||||
{
|
||||
Version ver = GetInstalledVer();
|
||||
if (ver.Major == 0 && ver.Minor == 0 && ver.Minor == 0) return "";
|
||||
@@ -36,7 +36,7 @@ namespace Flowframes.OS
|
||||
}
|
||||
}
|
||||
|
||||
public static VersionCompareResult CompareVersions (Version currentVersion, Version newVersion)
|
||||
public static VersionCompareResult CompareVersions(Version currentVersion, Version newVersion)
|
||||
{
|
||||
Logger.Log($"Checking if {newVersion} > {currentVersion}", true);
|
||||
int result = newVersion.CompareTo(currentVersion);
|
||||
@@ -57,7 +57,7 @@ namespace Flowframes.OS
|
||||
return VersionCompareResult.Equal;
|
||||
}
|
||||
|
||||
public static Version GetLatestVer (bool patreon)
|
||||
public static Version GetLatestVer(bool patreon)
|
||||
{
|
||||
var client = new WebClient();
|
||||
int line = patreon ? 0 : 2;
|
||||
@@ -79,7 +79,7 @@ namespace Flowframes.OS
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task UpdateTo (int version, UpdaterForm form = null)
|
||||
public static async Task UpdateTo(int version, UpdaterForm form = null)
|
||||
{
|
||||
Logger.Log("Updating to " + version, true);
|
||||
string savePath = Path.Combine(Paths.GetExeDir(), $"FlowframesV{version}");
|
||||
@@ -128,7 +128,7 @@ namespace Flowframes.OS
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
public static async Task AsyncUpdateCheck ()
|
||||
public static async Task AsyncUpdateCheck()
|
||||
{
|
||||
Version installed = GetInstalledVer();
|
||||
Version latestPat = GetLatestVer(true);
|
||||
@@ -139,15 +139,23 @@ namespace Flowframes.OS
|
||||
|
||||
public static async Task UpdateModelList()
|
||||
{
|
||||
try
|
||||
foreach (AI ai in Networks.networks)
|
||||
{
|
||||
foreach(AI ai in Networks.networks)
|
||||
try
|
||||
{
|
||||
var client = new WebClient();
|
||||
string aiName = ai.pkgDir;
|
||||
string url = $"https://raw.githubusercontent.com/n00mkrad/flowframes/main/Pkgs/{aiName}/models.txt";
|
||||
string movePath = Path.Combine(Paths.GetPkgPath(), aiName, "models.txt");
|
||||
string savePath = movePath + ".tmp";
|
||||
|
||||
if (!Directory.Exists(savePath.GetParentDir()))
|
||||
{
|
||||
Logger.Log($"Skipping {ai.pkgDir} models file download as '{savePath.GetParentDir()}' does not exist!", true);
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger.Log($"Saving models file from '{url}' to '{savePath}'", true);
|
||||
client.DownloadFile(url, savePath);
|
||||
|
||||
if (IOUtils.GetFilesize(savePath) > 8)
|
||||
@@ -162,11 +170,11 @@ namespace Flowframes.OS
|
||||
|
||||
Program.mainForm.UpdateAiModelCombox();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Failed to fetch models file. Ignore this if you are not connected to the internet.");
|
||||
Logger.Log($"{e.Message}\n{e.StackTrace}", true);
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Failed to fetch models file for {ai.friendlyName}. Ignore this if you are not connected to the internet.");
|
||||
Logger.Log($"{e.Message}\n{e.StackTrace}", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,32 @@ namespace Flowframes.UI
|
||||
{
|
||||
public static async Task LoadNews (Label newsLabel)
|
||||
{
|
||||
string url = $"https://raw.githubusercontent.com/n00mkrad/flowframes/main/changelog.txt";
|
||||
var client = new WebClient();
|
||||
var str = await client.DownloadStringTaskAsync(new Uri(url));
|
||||
newsLabel.Text = str;
|
||||
try
|
||||
{
|
||||
string url = $"https://raw.githubusercontent.com/n00mkrad/flowframes/main/changelog.txt";
|
||||
var client = new WebClient();
|
||||
var str = await client.DownloadStringTaskAsync(new Uri(url));
|
||||
newsLabel.Text = str;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.Log($"Failed to load news: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task LoadPatronListCsv(Label patronsLabel)
|
||||
{
|
||||
string url = $"https://raw.githubusercontent.com/n00mkrad/flowframes/main/patrons.csv";
|
||||
var client = new WebClient();
|
||||
var csvData = await client.DownloadStringTaskAsync(new Uri(url));
|
||||
patronsLabel.Text = ParsePatreonCsv(csvData);
|
||||
try
|
||||
{
|
||||
string url = $"https://raw.githubusercontent.com/n00mkrad/flowframes/main/patrons.csv";
|
||||
var client = new WebClient();
|
||||
var csvData = await client.DownloadStringTaskAsync(new Uri(url));
|
||||
patronsLabel.Text = ParsePatreonCsv(csvData);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Failed to load patreon CSV: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static string ParsePatreonCsv(string csvData)
|
||||
|
||||
Reference in New Issue
Block a user