mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-07-10 04:21:49 +02:00
Model Downloader Cancel is now instant + other improvements
This commit is contained in:
@@ -63,11 +63,12 @@ namespace Flowframes.Forms
|
||||
|
||||
private void cancelBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
ModelDownloadFormUtils.canceled = true;
|
||||
ModelDownloadFormUtils.Cancel();
|
||||
}
|
||||
|
||||
private void closeBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
ModelDownloadFormUtils.Cancel();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,14 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flowframes.IO
|
||||
{
|
||||
class ModelDownloader
|
||||
{
|
||||
public static bool canceled = false;
|
||||
|
||||
static string GetMdlUrl (string ai, string relPath)
|
||||
{
|
||||
@@ -34,6 +33,7 @@ namespace Flowframes.IO
|
||||
|
||||
static async Task DownloadTo (string url, string saveDirOrPath, bool log = true, int retries = 3)
|
||||
{
|
||||
canceled = false;
|
||||
string savePath = saveDirOrPath;
|
||||
|
||||
if (IOUtils.IsPathDirectory(saveDirOrPath))
|
||||
@@ -68,12 +68,13 @@ namespace Flowframes.IO
|
||||
|
||||
while (!completed)
|
||||
{
|
||||
if (Interpolate.canceled)
|
||||
if (canceled || Interpolate.canceled)
|
||||
{
|
||||
client.CancelAsync();
|
||||
client.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
if (sw.ElapsedMilliseconds > 6000)
|
||||
{
|
||||
client.CancelAsync();
|
||||
@@ -87,6 +88,7 @@ namespace Flowframes.IO
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ using Flowframes.IO;
|
||||
using Flowframes.Main;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flowframes.MiscUtils
|
||||
@@ -15,7 +13,7 @@ namespace Flowframes.MiscUtils
|
||||
public static ModelDownloadForm form;
|
||||
static int taskCounter = 0;
|
||||
static int tasksToDo = 0;
|
||||
public static bool canceled = false;
|
||||
static bool canceled = false;
|
||||
|
||||
public static async Task DownloadAll ()
|
||||
{
|
||||
@@ -50,6 +48,12 @@ namespace Flowframes.MiscUtils
|
||||
}
|
||||
}
|
||||
|
||||
public static void Cancel ()
|
||||
{
|
||||
canceled = true;
|
||||
ModelDownloader.canceled = true;
|
||||
}
|
||||
|
||||
public static int GetTaskCount (AI[] ais)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Flowframes.UI
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.Log($"Failed to load news: {e.Message}");
|
||||
Logger.Log($"Failed to load news: {e.Message}", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Flowframes.UI
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Failed to load patreon CSV: {e.Message}");
|
||||
Logger.Log($"Failed to load patreon CSV: {e.Message}", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user