Remove unused code

This commit is contained in:
N00MKRAD
2024-09-28 18:15:26 +02:00
parent 53b82765dd
commit 76defc4c19
2 changed files with 7 additions and 63 deletions

View File

@@ -3,9 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Flowframes.MiscUtils;
@@ -20,23 +18,21 @@ namespace Flowframes.IO
public static bool SymlinksAllowed()
{
string origFile = Paths.GetExe();
string linkPath = Paths.GetExe() + "linktest";
string linkPath = Paths.GetExe() + "lnktest";
bool success = CreateSymbolicLink(linkPath, origFile, Flag.Unprivileged);
if (success)
{
File.Delete(linkPath);
return true;
}
if (!success)
return false;
return false;
File.Delete(linkPath);
return true;
}
public static async Task CreateSymlinksParallel(Dictionary<string, string> pathsLinkTarget, bool debug = false, int maxThreads = 150)
{
Stopwatch sw = new Stopwatch();
sw.Restart();
ParallelOptions opts = new ParallelOptions() {MaxDegreeOfParallelism = maxThreads};
ParallelOptions opts = new ParallelOptions() { MaxDegreeOfParallelism = maxThreads };
Task forEach = Task.Run(async () => Parallel.ForEach(pathsLinkTarget, opts, pair =>
{

View File

@@ -1,13 +1,10 @@
using Flowframes.Data;
using Flowframes.Forms;
using Flowframes.IO;
using Flowframes.Ui;
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
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()
{
Version installed = GetInstalledVer();