mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 08:27:44 +01:00
Remove unused code
This commit is contained in:
@@ -3,9 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Flowframes.MiscUtils;
|
using Flowframes.MiscUtils;
|
||||||
|
|
||||||
@@ -20,23 +18,21 @@ namespace Flowframes.IO
|
|||||||
public static bool SymlinksAllowed()
|
public static bool SymlinksAllowed()
|
||||||
{
|
{
|
||||||
string origFile = Paths.GetExe();
|
string origFile = Paths.GetExe();
|
||||||
string linkPath = Paths.GetExe() + "linktest";
|
string linkPath = Paths.GetExe() + "lnktest";
|
||||||
bool success = CreateSymbolicLink(linkPath, origFile, Flag.Unprivileged);
|
bool success = CreateSymbolicLink(linkPath, origFile, Flag.Unprivileged);
|
||||||
|
|
||||||
if (success)
|
if (!success)
|
||||||
{
|
return false;
|
||||||
File.Delete(linkPath);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
File.Delete(linkPath);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task CreateSymlinksParallel(Dictionary<string, string> pathsLinkTarget, bool debug = false, int maxThreads = 150)
|
public static async Task CreateSymlinksParallel(Dictionary<string, string> pathsLinkTarget, bool debug = false, int maxThreads = 150)
|
||||||
{
|
{
|
||||||
Stopwatch sw = new Stopwatch();
|
Stopwatch sw = new Stopwatch();
|
||||||
sw.Restart();
|
sw.Restart();
|
||||||
ParallelOptions opts = new ParallelOptions() {MaxDegreeOfParallelism = maxThreads};
|
ParallelOptions opts = new ParallelOptions() { MaxDegreeOfParallelism = maxThreads };
|
||||||
|
|
||||||
Task forEach = Task.Run(async () => Parallel.ForEach(pathsLinkTarget, opts, pair =>
|
Task forEach = Task.Run(async () => Parallel.ForEach(pathsLinkTarget, opts, pair =>
|
||||||
{
|
{
|
||||||
@@ -53,7 +49,7 @@ namespace Flowframes.IO
|
|||||||
public static async Task<bool> MakeSymlinksForEncode(string framesFile, string linksDir, int zPad = 8)
|
public static async Task<bool> MakeSymlinksForEncode(string framesFile, string linksDir, int zPad = 8)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IoUtils.DeleteIfExists(linksDir);
|
IoUtils.DeleteIfExists(linksDir);
|
||||||
Directory.CreateDirectory(linksDir);
|
Directory.CreateDirectory(linksDir);
|
||||||
Stopwatch sw = new Stopwatch();
|
Stopwatch sw = new Stopwatch();
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
using Flowframes.Data;
|
using Flowframes.Data;
|
||||||
using Flowframes.Forms;
|
|
||||||
using Flowframes.IO;
|
using Flowframes.IO;
|
||||||
using Flowframes.Ui;
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Flowframes.Os
|
namespace Flowframes.Os
|
||||||
{
|
{
|
||||||
@@ -85,55 +82,6 @@ namespace Flowframes.Os
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task UpdateTo(int version, UpdaterForm form = null)
|
|
||||||
{
|
|
||||||
Logger.Log("Updating to " + version, true);
|
|
||||||
string savePath = Path.Combine(Paths.GetExeDir(), $"FlowframesV{version}");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var client = new WebClient();
|
|
||||||
client.DownloadProgressChanged += async (sender, args) =>
|
|
||||||
{
|
|
||||||
if (form != null && (args.ProgressPercentage % 5 == 0))
|
|
||||||
{
|
|
||||||
Logger.Log("Downloading update... " + args.ProgressPercentage, true);
|
|
||||||
form.SetProgLabel(args.ProgressPercentage, $"Downloading latest version... {args.ProgressPercentage}%");
|
|
||||||
await Task.Delay(20);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
client.DownloadFileCompleted += (sender, args) =>
|
|
||||||
{
|
|
||||||
form.SetProgLabel(100f, $"Downloading latest version... 100%");
|
|
||||||
};
|
|
||||||
await client.DownloadFileTaskAsync(new Uri($"https://dl.nmkd.de/flowframes/exe/{version}/Flowframes.exe"), savePath);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
UiUtils.ShowMessageBox("Error: Failed to download update.\n\n" + e.Message, UiUtils.MessageType.Error);
|
|
||||||
Logger.Log("Updater Error during download: " + e.Message, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Logger.Log("Installing v" + version, true);
|
|
||||||
string runningExePath = Paths.GetExe();
|
|
||||||
string oldExePath = runningExePath + ".old";
|
|
||||||
IoUtils.TryDeleteIfExists(oldExePath);
|
|
||||||
File.Move(runningExePath, oldExePath);
|
|
||||||
File.Move(savePath, runningExePath);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
UiUtils.ShowMessageBox("Error: Failed to install update.\n\n" + e.Message, UiUtils.MessageType.Error);
|
|
||||||
Logger.Log("Updater Error during install: " + e.Message, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
form.SetProgLabel(101f, $"Update downloaded.");
|
|
||||||
await Task.Delay(20);
|
|
||||||
UiUtils.ShowMessageBox("Update was installed!\nFlowframes will now close. Restart it to use the new version.");
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task AsyncUpdateCheck()
|
public static async Task AsyncUpdateCheck()
|
||||||
{
|
{
|
||||||
Version installed = GetInstalledVer();
|
Version installed = GetInstalledVer();
|
||||||
|
|||||||
Reference in New Issue
Block a user