auto update model list

This commit is contained in:
Richard
2021-02-26 23:25:27 +01:00
parent 8699a5a7fb
commit 1d0e2a6c5e
2 changed files with 22 additions and 3 deletions

View File

@@ -70,6 +70,7 @@ namespace Flowframes
GetWebInfo.LoadNews(newsLabel); GetWebInfo.LoadNews(newsLabel);
GetWebInfo.LoadPatronListCsv(patronsLabel); GetWebInfo.LoadPatronListCsv(patronsLabel);
Updater.AsyncUpdateCheck(); Updater.AsyncUpdateCheck();
Updater.UpdateModelList();
Python.CheckCompression(); Python.CheckCompression();
} }
catch (Exception e) catch (Exception e)

View File

@@ -2,11 +2,8 @@
using Flowframes.Forms; using Flowframes.Forms;
using Flowframes.IO; using Flowframes.IO;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Net; using System.Net;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@@ -132,5 +129,26 @@ namespace Flowframes.OS
Logger.Log($"You are running Flowframes {installed}. The latest Patreon version is {latestPat}, the latest free version is {latestFree}."); Logger.Log($"You are running Flowframes {installed}. The latest Patreon version is {latestPat}, the latest free version is {latestFree}.");
} }
public static async Task UpdateModelList()
{
try
{
Networks.networks.ForEach(ai =>
{
var client = new WebClient();
string aiName = Path.GetFileNameWithoutExtension(ai.pkg.fileName);
string url = $"https://raw.githubusercontent.com/n00mkrad/flowframes/main/Pkgs/{aiName}/models.txt";
string savePath = Path.Combine(Paths.GetPkgPath(), aiName, "models.txt");
if(File.Exists(savePath)) File.Delete(savePath);
client.DownloadFile(url, savePath);
});
}
catch (Exception e)
{
Logger.Log("Non-critical error while performing model list update. See logs for details.");
Logger.Log($"{e.Message}\n{e.StackTrace}", true);
}
}
} }
} }