diff --git a/CodeLegacy/IO/Symlinks.cs b/CodeLegacy/IO/Symlinks.cs index b1aee13..b973688 100644 --- a/CodeLegacy/IO/Symlinks.cs +++ b/CodeLegacy/IO/Symlinks.cs @@ -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 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 => { @@ -53,7 +49,7 @@ namespace Flowframes.IO public static async Task MakeSymlinksForEncode(string framesFile, string linksDir, int zPad = 8) { try - { + { IoUtils.DeleteIfExists(linksDir); Directory.CreateDirectory(linksDir); Stopwatch sw = new Stopwatch(); diff --git a/CodeLegacy/Os/Updater.cs b/CodeLegacy/Os/Updater.cs index f6dbac2..6fccdc9 100644 --- a/CodeLegacy/Os/Updater.cs +++ b/CodeLegacy/Os/Updater.cs @@ -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();