2020-11-23 16:51:05 +01:00
|
|
|
|
using Flowframes.Data;
|
|
|
|
|
|
using Flowframes.IO;
|
|
|
|
|
|
using Flowframes.OS;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
2021-03-30 13:17:04 +02:00
|
|
|
|
[assembly: System.Windows.Media.DisableDpiAwareness] // Disable Dpi awareness in the application assembly.
|
|
|
|
|
|
|
2020-11-23 16:51:05 +01:00
|
|
|
|
namespace Flowframes
|
|
|
|
|
|
{
|
|
|
|
|
|
static class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
public static Form1 mainForm;
|
|
|
|
|
|
|
|
|
|
|
|
public static bool busy = false;
|
|
|
|
|
|
|
|
|
|
|
|
public static string lastInputPath;
|
|
|
|
|
|
public static bool lastInputPathIsSsd;
|
|
|
|
|
|
|
2020-12-17 11:32:45 +01:00
|
|
|
|
public static Queue<InterpSettings> batchQueue = new Queue<InterpSettings>();
|
2020-11-23 16:51:05 +01:00
|
|
|
|
|
|
|
|
|
|
[STAThread]
|
|
|
|
|
|
static void Main()
|
|
|
|
|
|
{
|
|
|
|
|
|
Config.Init();
|
|
|
|
|
|
|
2020-11-27 09:45:06 +01:00
|
|
|
|
if (Config.GetBool("delLogsOnStartup"))
|
2021-02-18 14:30:56 +01:00
|
|
|
|
IOUtils.DeleteContentsOfDir(Paths.GetLogPath()); // Clear out older logs from previous session
|
2020-11-23 16:51:05 +01:00
|
|
|
|
|
|
|
|
|
|
Networks.Init();
|
|
|
|
|
|
|
2021-03-09 19:20:47 +01:00
|
|
|
|
Task.Run(() => DiskSpaceCheckLoop());
|
|
|
|
|
|
|
2020-11-23 16:51:05 +01:00
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
|
|
|
|
|
|
|
mainForm = new Form1();
|
|
|
|
|
|
Application.Run(mainForm);
|
2021-03-09 19:20:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static async Task DiskSpaceCheckLoop ()
|
|
|
|
|
|
{
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (busy)
|
|
|
|
|
|
{
|
2021-03-19 19:34:48 +01:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-03-22 21:40:21 +01:00
|
|
|
|
if (Interpolate.current.tempFolder.Length < 3)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2021-03-19 19:34:48 +01:00
|
|
|
|
string drivePath = Interpolate.current.tempFolder.Substring(0, 2);
|
|
|
|
|
|
long mb = IOUtils.GetDiskSpace(Interpolate.current.tempFolder);
|
2021-03-09 19:20:47 +01:00
|
|
|
|
|
2021-03-19 19:34:48 +01:00
|
|
|
|
Logger.Log($"Disk space check for '{drivePath}/': {(mb / 1024f).ToString("0.0")} GB free.", true);
|
2021-03-09 19:20:47 +01:00
|
|
|
|
|
2021-03-19 19:34:48 +01:00
|
|
|
|
if (!Interpolate.canceled && mb < (Config.GetInt("minDiskSpaceGb", 6) * 1024))
|
|
|
|
|
|
Interpolate.Cancel("Running out of disk space!");
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
// Disk space check failed, this is not critical and might just be caused by a null ref
|
|
|
|
|
|
}
|
2021-03-09 19:20:47 +01:00
|
|
|
|
}
|
2020-11-23 16:51:05 +01:00
|
|
|
|
|
2021-03-09 19:20:47 +01:00
|
|
|
|
await Task.Delay(15000);
|
|
|
|
|
|
}
|
2020-11-23 16:51:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|