diff --git a/.idea/.idea.UpTool2/.idea/codeStyles/codeStyleConfig.xml b/.idea/.idea.UpTool2/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/.idea.UpTool2/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Installer/InstallerForm.Designer.cs b/Installer/InstallerForm.Designer.cs
index a0d0243..db19102 100644
--- a/Installer/InstallerForm.Designer.cs
+++ b/Installer/InstallerForm.Designer.cs
@@ -27,50 +27,62 @@
///
private void InitializeComponent()
{
- System.ComponentModel.ComponentResourceManager resources =
- new System.ComponentModel.ComponentResourceManager(typeof(Installer.InstallerForm));
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InstallerForm));
this.install = new System.Windows.Forms.Button();
this.installLabel = new System.Windows.Forms.Label();
this.progress = new System.Windows.Forms.ProgressBar();
this.processLabel = new System.Windows.Forms.Label();
this.log = new System.Windows.Forms.Button();
+ this.startupBox = new System.Windows.Forms.CheckBox();
+ this.pathBox = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
- this.install.Anchor =
- ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Bottom |
- System.Windows.Forms.AnchorStyles.Left) |
- System.Windows.Forms.AnchorStyles.Right)));
- this.install.Location = new System.Drawing.Point(12, 92);
+ //
+ // install
+ //
+ this.install.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.install.Location = new System.Drawing.Point(12, 116);
this.install.Name = "install";
this.install.Size = new System.Drawing.Size(539, 27);
this.install.TabIndex = 0;
this.install.Text = "Install";
this.install.UseVisualStyleBackColor = true;
this.install.Click += new System.EventHandler(this.install_Click);
+ //
+ // installLabel
+ //
this.installLabel.AutoSize = true;
this.installLabel.Location = new System.Drawing.Point(12, 9);
this.installLabel.Name = "installLabel";
this.installLabel.Size = new System.Drawing.Size(550, 75);
this.installLabel.TabIndex = 1;
this.installLabel.Text = resources.GetString("installLabel.Text");
- this.progress.Anchor =
- ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Bottom |
- System.Windows.Forms.AnchorStyles.Left) |
- System.Windows.Forms.AnchorStyles.Right)));
- this.progress.Location = new System.Drawing.Point(12, 92);
+ //
+ // progress
+ //
+ this.progress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.progress.Location = new System.Drawing.Point(12, 116);
this.progress.Maximum = 8;
this.progress.Name = "progress";
this.progress.Size = new System.Drawing.Size(539, 27);
this.progress.TabIndex = 2;
this.progress.Visible = false;
+ //
+ // processLabel
+ //
+ this.processLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
this.processLabel.ForeColor = System.Drawing.SystemColors.ControlText;
- this.processLabel.Location = new System.Drawing.Point(422, 70);
+ this.processLabel.Location = new System.Drawing.Point(258, 94);
this.processLabel.Name = "processLabel";
- this.processLabel.Size = new System.Drawing.Size(129, 19);
+ this.processLabel.Size = new System.Drawing.Size(293, 19);
this.processLabel.TabIndex = 3;
this.processLabel.TextAlign = System.Drawing.ContentAlignment.TopRight;
- this.log.Anchor =
- ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
- System.Windows.Forms.AnchorStyles.Right)));
+ //
+ // log
+ //
+ this.log.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.log.Location = new System.Drawing.Point(524, 3);
this.log.Name = "log";
this.log.Size = new System.Drawing.Size(36, 23);
@@ -79,21 +91,49 @@
this.log.UseVisualStyleBackColor = true;
this.log.Visible = false;
this.log.Click += new System.EventHandler(this.log_Click);
+ //
+ // startupBox
+ //
+ this.startupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.startupBox.AutoSize = true;
+ this.startupBox.Enabled = false;
+ this.startupBox.Location = new System.Drawing.Point(130, 91);
+ this.startupBox.Name = "startupBox";
+ this.startupBox.Size = new System.Drawing.Size(122, 19);
+ this.startupBox.TabIndex = 5;
+ this.startupBox.Text = "Update on Startup";
+ //
+ // pathBox
+ //
+ this.pathBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.pathBox.AutoSize = true;
+ this.pathBox.Location = new System.Drawing.Point(12, 91);
+ this.pathBox.Name = "pathBox";
+ this.pathBox.Size = new System.Drawing.Size(112, 19);
+ this.pathBox.TabIndex = 6;
+ this.pathBox.Text = "Register in PATH";
+ this.pathBox.CheckedChanged += new System.EventHandler(this.pathBox_CheckedChanged);
+ //
+ // InstallerForm
+ //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(563, 132);
+ this.ClientSize = new System.Drawing.Size(563, 156);
this.Controls.Add(this.log);
this.Controls.Add(this.processLabel);
this.Controls.Add(this.progress);
this.Controls.Add(this.installLabel);
this.Controls.Add(this.install);
+ this.Controls.Add(this.startupBox);
+ this.Controls.Add(this.pathBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
- this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
+ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "InstallerForm";
this.ShowIcon = false;
this.Text = "UpTool2 Installer";
this.ResumeLayout(false);
this.PerformLayout();
+
}
#endregion
@@ -102,6 +142,8 @@
private System.Windows.Forms.ProgressBar progress;
private System.Windows.Forms.Label processLabel;
private System.Windows.Forms.Button log;
+ private System.Windows.Forms.CheckBox pathBox;
+ private System.Windows.Forms.CheckBox startupBox;
}
}
diff --git a/Installer/InstallerForm.cs b/Installer/InstallerForm.cs
index 1eacb22..7ab44b7 100644
--- a/Installer/InstallerForm.cs
+++ b/Installer/InstallerForm.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.Win32;
+using System;
using System.Drawing;
using System.Globalization;
using System.IO;
@@ -17,6 +18,8 @@ namespace Installer
public partial class InstallerForm : Form
{
private string _log = "";
+ private const string AppName = "UpTool2";
+ private readonly RegistryKey _rkApp;
public InstallerForm()
{
@@ -24,6 +27,9 @@ namespace Installer
InitializeComponent();
Step(0, "Initialized");
_log = _log.TrimStart(Environment.NewLine.ToCharArray());
+ _rkApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
+ startupBox.Checked = _rkApp.GetValue(AppName) != null;
+ pathBox.Checked = Path.Content.Contains(Path.GetName(PathTool.GetRelative("Install")));
}
private void install_Click(object sender, EventArgs e)
@@ -44,7 +50,9 @@ namespace Installer
string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
if (pkgHash != meta.Element("Hash").Value.ToUpper())
throw new Exception(
- $"The hash is not equal to the one stored in the repo:\r\nPackage: {pkgHash}\r\nOnline: {meta.Element("Hash").Value.ToUpper()}");
+ $@"The hash is not equal to the one stored in the repo:
+Package: {pkgHash}
+Online: {meta.Element("Hash").Value.ToUpper()}");
}
Step(4, "Extracting");
if (Directory.Exists(PathTool.GetRelative("Install")))
@@ -57,13 +65,21 @@ namespace Installer
}
Step(5, "Creating shortcut");
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"),
- System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
- Step(6, "Creating PATH entry");
- if (!Path.Content.Contains(Path.GetName(PathTool.GetRelative("Install"))))
- Path.Append(PathTool.GetRelative("Install"));
- Step(7, "Preparing Repos");
+ System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
+ "UpTool2.lnk"));
+ Step(6, "Preparing Repos");
XmlTool.FixXml();
RepoManagement.FetchRepos();
+ if (pathBox.Checked)
+ {
+ Step(7, startupBox.Checked ? "Creating PATH & Autostart entry" : "Creating PATH entry");
+ if (!Path.Content.Contains(Path.GetName(PathTool.GetRelative("Install"))))
+ Path.Append(PathTool.GetRelative("Install"));
+ if (startupBox.Checked)
+ _rkApp.SetValue(AppName, "uptool upgrade-self");
+ else if (_rkApp.GetValue(AppName) != null)
+ _rkApp.DeleteValue(AppName, false);
+ }
Step(8, "Done!");
}
catch (Exception ex)
@@ -94,8 +110,16 @@ namespace Installer
Log(text);
}
- private void Log(string text) => _log += $"{Environment.NewLine}[{DateTime.Now.ToString(CultureInfo.InvariantCulture).Split(' ')[1]}] {text}";
+ private void Log(string text) => _log +=
+ $"{Environment.NewLine}[{DateTime.Now.ToString(CultureInfo.InvariantCulture).Split(' ')[1]}] {text}";
private void log_Click(object sender, EventArgs e) => new Thread(() => MessageBox.Show(_log)).Start();
+
+ private void pathBox_CheckedChanged(object sender, EventArgs e)
+ {
+ startupBox.Enabled = pathBox.Checked;
+ if (!pathBox.Checked)
+ startupBox.Checked = false;
+ }
}
}
\ No newline at end of file
diff --git a/Installer/PATH.cs b/Installer/PATH.cs
index 7c33388..7ad39bf 100644
--- a/Installer/PATH.cs
+++ b/Installer/PATH.cs
@@ -1,5 +1,4 @@
using System;
-using System.IO;
using System.Linq;
namespace Installer
diff --git a/Installer/Program.cs b/Installer/Program.cs
index 78985c2..a4b73f3 100644
--- a/Installer/Program.cs
+++ b/Installer/Program.cs
@@ -6,7 +6,6 @@ using System.Net;
using System.Security.Cryptography;
using System.Threading;
using System.Windows.Forms;
-using System.Xml.Linq;
using UpToolLib;
using UpToolLib.Tool;
@@ -43,7 +42,8 @@ namespace Installer
Console.WriteLine("Verifying integrity");
using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
{
- string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
+ string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty)
+ .ToUpper();
if (pkgHash != UpdateCheck.AppHash)
throw new Exception($@"The hash is not equal to the one stored in the repo:
Package: {pkgHash}
@@ -65,7 +65,8 @@ Online: {UpdateCheck.AppHash}");
}
Console.WriteLine("Creating shortcut");
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"),
- System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
+ System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
+ "UpTool2.lnk"));
Console.WriteLine("Creating PATH entry");
if (!Path.Content.Contains(Path.GetName(PathTool.GetRelative("Install"))))
Path.Append(PathTool.GetRelative("Install"));
diff --git a/Installer/UTLibFunctions_CLI.cs b/Installer/UTLibFunctions_CLI.cs
index 6daac2c..1244b0c 100644
--- a/Installer/UTLibFunctions_CLI.cs
+++ b/Installer/UTLibFunctions_CLI.cs
@@ -27,7 +27,7 @@ namespace Installer
client.DownloadProgressChanged += (sender, e) =>
{
Console.Write(
- $"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - (e.ProgressPercentage / 10))}");
+ $"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - e.ProgressPercentage / 10)}");
Console.CursorLeft = 0;
};
client.DownloadDataAsync(link);
@@ -108,7 +108,9 @@ namespace Installer
public object GetDefaultIcon() => 0;
- public object ImageFromB64(string b64) => (Bitmap) new ImageConverter().ConvertFrom(Convert.FromBase64String(b64));
+ public object ImageFromB64(string b64) =>
+ (Bitmap) new ImageConverter().ConvertFrom(Convert.FromBase64String(b64));
+
public void Log(string text) => Console.WriteLine(text);
}
}
\ No newline at end of file
diff --git a/Installer/UTLibFunctions_GUI.cs b/Installer/UTLibFunctions_GUI.cs
index 4be5e75..bd6c439 100644
--- a/Installer/UTLibFunctions_GUI.cs
+++ b/Installer/UTLibFunctions_GUI.cs
@@ -11,7 +11,7 @@ namespace Installer
{
internal class UtLibFunctionsGui : IExternalFunctionality
{
- private Action _log;
+ private readonly Action _log;
public UtLibFunctionsGui(Action log) => _log = log;
public Tuple Download(Uri link)
diff --git a/UpTool build tool/BatchScripts.cs b/UpTool build tool/BatchScripts.cs
index c15dbf1..7eed18a 100644
--- a/UpTool build tool/BatchScripts.cs
+++ b/UpTool build tool/BatchScripts.cs
@@ -5,7 +5,8 @@ namespace UpTool_build_tool
{
internal static class BatchScripts
{
- public static Tuple Create(bool shortcuts, string? mainBin, string programName, string? postInstall, string? postRemove)
+ public static Tuple Create(bool shortcuts, string? mainBin, string programName,
+ string? postInstall, string? postRemove)
{
string installBat = "@echo off\r\necho INSTALL";
string removeBat = "@echo off\r\necho REMOVE";
diff --git a/UpTool build tool/Program.cs b/UpTool build tool/Program.cs
index ff93aa4..7b11aae 100644
--- a/UpTool build tool/Program.cs
+++ b/UpTool build tool/Program.cs
@@ -19,15 +19,18 @@ namespace UpTool_build_tool
new Option("--binDir", "Directory to package"),
new Option("--mainBin", () => "FIND_BIN", "The applications main binary"),
new Option("--packageFile", "Directory to package"),
- new Option("--postInstall", () => "", "Command(s) to run after installing the package (This will be pasted into the .bat AND .sh file)"),
- new Option("--postRemove", () => "", "Command(s) to run after removing the package (This will be pasted into the .bat AND .sh file)"),
+ new Option("--postInstall", () => "",
+ "Command(s) to run after installing the package (This will be pasted into the .bat AND .sh file)"),
+ new Option("--postRemove", () => "",
+ "Command(s) to run after removing the package (This will be pasted into the .bat AND .sh file)"),
new Option("--noLogo", "Disables the logo"),
new Option("--noShortcuts",
"When this is enabled the scripts will not generate a start-menu item"),
new Option("--noWine",
"This indicates that your program supports multiple platforms natively and doesn't require WINE")
};
- build.Handler = CommandHandler.Create((Action)Build);
+ build.Handler =
+ CommandHandler.Create((Action) Build);
rootCommand.AddCommand(build);
return rootCommand.InvokeAsync(args).Result;
}
@@ -71,11 +74,11 @@ namespace UpTool_build_tool
}
}
string programName = Path.GetFileNameWithoutExtension(mainBin);
- (string installBat, string removeBat) = BatchScripts.Create(!noShortcuts, mainBin, programName, postInstall, postRemove);
+ (string installBat, string removeBat) =
+ BatchScripts.Create(!noShortcuts, mainBin, programName, postInstall, postRemove);
archive.AddFile("Install.bat", installBat);
archive.AddFile("Remove.bat", removeBat);
ShScripts.Create(archive.AddFile, !noShortcuts, mainBin, programName, postInstall, postRemove, !noWine);
-
}
watch.Stop();
Console.WriteLine($"Completed package creation in {watch.Elapsed}");
diff --git a/UpTool build tool/ShScripts.cs b/UpTool build tool/ShScripts.cs
index 0f0f33d..75a042f 100644
--- a/UpTool build tool/ShScripts.cs
+++ b/UpTool build tool/ShScripts.cs
@@ -5,7 +5,8 @@ namespace UpTool_build_tool
{
internal static class ShScripts
{
- public static void Create(Action fileSave, bool shortcuts, string? mainBin, string programName, string? postInstall, string? postRemove, bool wine)
+ public static void Create(Action fileSave, bool shortcuts, string? mainBin, string programName,
+ string? postInstall, string? postRemove, bool wine)
{
Regex rgx = new Regex("[^a-z0-9]");
Regex upRgx = new Regex("[^a-zA-Z0-9 -]");
diff --git a/UpTool2/MainForm.cs b/UpTool2/MainForm.cs
index c6b3663..4a2b982 100644
--- a/UpTool2/MainForm.cs
+++ b/UpTool2/MainForm.cs
@@ -27,9 +27,7 @@ namespace UpTool2
HelpRequested += _help;
filterBox.DataSource = Enum.GetValues(typeof(Status));
if (Program.Online)
- {
RepoManagement.FetchRepos();
- }
else
{
MessageBox.Show("Starting in offline mode!");
@@ -240,9 +238,7 @@ namespace UpTool2
private void MainForm_Load(object sender, EventArgs e)
{
if (Program.Splash.IsDisposed)
- {
Close();
- }
else
{
Program.Splash.Invoke((Action) Program.Splash.Hide);
diff --git a/UpTool2/Program.cs b/UpTool2/Program.cs
index 9107c3c..21571ef 100644
--- a/UpTool2/Program.cs
+++ b/UpTool2/Program.cs
@@ -5,11 +5,8 @@ using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Security.Cryptography;
-using System.Threading;
using System.Windows.Forms;
using System.Xml;
-using System.Xml.Linq;
-using CC_Functions.Misc;
using UpTool2.Tool;
using UpToolLib;
using UpToolLib.Tool;
@@ -118,7 +115,7 @@ namespace UpTool2
const int barWidth = 50;
const int topOffset = 100;
for (int i = 0; i < Splash.Width + topOffset; i += barWidth)
- g.FillPolygon(brushes[(i / barWidth) % brushes.Length], new[]
+ g.FillPolygon(brushes[i / barWidth % brushes.Length], new[]
{
new PointF(i, 0),
new PointF(i + barWidth, 0),
@@ -129,8 +126,8 @@ namespace UpTool2
Font font = new Font(FontFamily.GenericSansSerif, 40, FontStyle.Bold);
const string text = "UpTool2";
SizeF size = g.MeasureString(text, font);
- RectangleF rect = new RectangleF((Splash.Width / 2f) - (size.Width / 2),
- (Splash.Height / 2f) - (size.Height / 2), size.Width, size.Height);
+ RectangleF rect = new RectangleF(Splash.Width / 2f - size.Width / 2,
+ Splash.Height / 2f - size.Height / 2, size.Width, size.Height);
g.DrawString(text, font, Brushes.White, rect);
Font smallFont = new Font(FontFamily.GenericSansSerif, 10);
const string subtitle = "by JFronny";
@@ -138,11 +135,11 @@ namespace UpTool2
g.DrawString(subtitle, smallFont, Brushes.White,
new RectangleF(rect.Right - size2.Width, rect.Bottom - size2.Height, size2.Width, size2.Height));
//Draw progress bar
- Rectangle bar = new Rectangle((3 * Splash.Width) / 8, ((Splash.Height * 3) / 4) - 10, Splash.Width / 4,
+ Rectangle bar = new Rectangle(3 * Splash.Width / 8, Splash.Height * 3 / 4 - 10, Splash.Width / 4,
20);
g.FillRectangle(Brushes.Gray, bar);
g.FillRectangle(Brushes.Black,
- new Rectangle(bar.X, bar.Y, (bar.Width * _splashProgress) / 10, bar.Height));
+ new Rectangle(bar.X, bar.Y, bar.Width * _splashProgress / 10, bar.Height));
g.DrawRectangle(Pens.DimGray, bar);
//g.DrawString(SplashMessage, smallFont, Brushes.White, new PointF(bar.Left, bar.Bottom));
g.DrawString(_splashMessage, smallFont, Brushes.White, bar,
@@ -233,4 +230,4 @@ namespace UpTool2
return false;
}
}
-}
+}
\ No newline at end of file
diff --git a/UpTool2/SourcesForm.cs b/UpTool2/SourcesForm.cs
index c1bda80..322060a 100644
--- a/UpTool2/SourcesForm.cs
+++ b/UpTool2/SourcesForm.cs
@@ -7,7 +7,6 @@ namespace UpTool2
public partial class SettingsForms : Form
{
private readonly XDocument _doc;
- private readonly XElement _meta;
private readonly XElement _repos;
public SettingsForms()
@@ -15,8 +14,7 @@ namespace UpTool2
InitializeComponent();
Program.FixXml();
_doc = XDocument.Load(PathTool.InfoXml);
- _meta = _doc.Element("meta");
- _repos = _meta.Element("Repos");
+ _repos = _doc.Element("meta").Element("Repos");
foreach (XElement repo in _repos.Elements("Repo"))
sourceGrid.Rows.Add(repo.Element("Name").Value, repo.Element("Link").Value);
}
diff --git a/UpToolCLI/Program.cs b/UpToolCLI/Program.cs
index c29a427..8e583f5 100644
--- a/UpToolCLI/Program.cs
+++ b/UpToolCLI/Program.cs
@@ -9,17 +9,17 @@ using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
-using System.Xml.Linq;
using UpToolLib;
using UpToolLib.DataStructures;
using UpToolLib.Tool;
-using Process = System.CommandLine.Invocation.Process;
+using Process = System.Diagnostics.Process;
namespace UpToolCLI
{
public static class Program
{
private static readonly UtLibFunctions Functions = new UtLibFunctions();
+
public static int Main(string[] args)
{
MutexLock.Lock();
@@ -122,37 +122,42 @@ namespace UpToolCLI
#if DEBUG
Console.WriteLine("Not enabled in debug builds");
#else
- Console.WriteLine("Downloading latest");
- (bool success, byte[] dl) = Functions.Download(UpdateCheck.Installer);
- if (!success)
- throw new Exception("Failed to update");
- Console.WriteLine("Verifying");
- using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
+ if (!force && Assembly.GetExecutingAssembly().GetName().Version >= UpdateCheck.OnlineVersion)
+ Console.WriteLine("Already up-to-date");
+ else
{
- string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
- if (pkgHash != UpdateCheck.InstallerHash)
- throw new Exception($@"The hash is not equal to the one stored in the repo:
+ Console.WriteLine("Downloading latest");
+ (bool success, byte[] dl) = Functions.Download(UpdateCheck.Installer);
+ if (!success)
+ throw new Exception("Failed to update");
+ Console.WriteLine("Verifying");
+ using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider())
+ {
+ string pkgHash = BitConverter.ToString(sha256.ComputeHash(dl)).Replace("-", string.Empty).ToUpper();
+ if (pkgHash != UpdateCheck.InstallerHash)
+ throw new Exception($@"The hash is not equal to the one stored in the repo:
Package: {pkgHash}
Online: {UpdateCheck.InstallerHash}");
+ }
+ Console.WriteLine("Installing");
+ if (Directory.Exists(PathTool.GetRelative("Install", "tmp")))
+ Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
+ Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
+ using (MemoryStream ms = new MemoryStream(dl))
+ {
+ using ZipArchive ar = new ZipArchive(ms);
+ ar.ExtractToDirectory(PathTool.GetRelative("Install", "tmp"), true);
+ }
+ string file = PathTool.GetRelative("Install", "tmp", "Installer.exe");
+ Console.WriteLine($"Starting {file}");
+ Process.Start(new ProcessStartInfo
+ {
+ FileName = file,
+ Arguments = "-i",
+ WorkingDirectory = PathTool.GetRelative("Install"),
+ UseShellExecute = false
+ });
}
- Console.WriteLine("Installing");
- if (Directory.Exists(PathTool.GetRelative("Install", "tmp")))
- Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
- Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
- using (MemoryStream ms = new MemoryStream(dl))
- {
- using ZipArchive ar = new ZipArchive(ms);
- ar.ExtractToDirectory(PathTool.GetRelative("Install", "tmp"), true);
- }
- string file = PathTool.GetRelative("Install", "tmp", "Installer.exe");
- Console.WriteLine($"Starting {file}");
- System.Diagnostics.Process.Start(new ProcessStartInfo
- {
- FileName = file,
- Arguments = "-i",
- WorkingDirectory = PathTool.GetRelative("Install"),
- UseShellExecute = false
- });
#endif
}
@@ -316,7 +321,8 @@ Online: {UpdateCheck.InstallerHash}");
{
Console.WriteLine("Name:");
string name = Console.ReadLine();
- AppInstall.InstallZip(identifier, new App(name, "Locally installed package, removal only", GlobalVariables.MinimumVer, "", true, "",
+ AppInstall.InstallZip(identifier, new App(name, "Locally installed package, removal only",
+ GlobalVariables.MinimumVer, "", true, "",
Guid.NewGuid(), Color.Red, "", false, ""), force);
Console.WriteLine($"Successfully installed \"{name}\"");
}
@@ -352,7 +358,7 @@ Online: {UpdateCheck.InstallerHash}");
if (tmp.Runnable)
{
Console.WriteLine($"Starting {tmp.Name}");
- System.Diagnostics.Process tmp1 = AppExtras.RunApp(tmp);
+ Process tmp1 = AppExtras.RunApp(tmp);
if (waitForExit)
tmp1.WaitForExit();
}
diff --git a/UpToolCLI/UTLibFunctions.cs b/UpToolCLI/UTLibFunctions.cs
index 51fe92e..19ef63d 100644
--- a/UpToolCLI/UTLibFunctions.cs
+++ b/UpToolCLI/UTLibFunctions.cs
@@ -26,7 +26,7 @@ namespace UpToolCLI
client.DownloadProgressChanged += (sender, e) =>
{
Console.Write(
- $"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - (e.ProgressPercentage / 10))}");
+ $"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - e.ProgressPercentage / 10)}");
Console.CursorLeft = 0;
};
client.DownloadDataAsync(link);
diff --git a/UpToolLib/GlobalVariables.cs b/UpToolLib/GlobalVariables.cs
index 34ff4ef..9085790 100644
--- a/UpToolLib/GlobalVariables.cs
+++ b/UpToolLib/GlobalVariables.cs
@@ -6,12 +6,13 @@ namespace UpToolLib
{
public static class GlobalVariables
{
- public static readonly Dictionary Apps = new Dictionary();
- public static Version MinimumVer => Version.Parse("0.0.0.0");
public const string Windows = "WINDOWS";
public const string Posix = "POSIX";
+ public static readonly Dictionary Apps = new Dictionary();
+ public static Version MinimumVer => Version.Parse("0.0.0.0");
public static string CurrentPlatform =>
- PlatformCheck.IsWindows ? Windows : PlatformCheck.IsPosix ? Posix : throw new Exception("Unexpeccted PlatformCheck");
+ PlatformCheck.IsWindows ? Windows :
+ PlatformCheck.IsPosix ? Posix : throw new Exception("Unexpeccted PlatformCheck");
}
}
\ No newline at end of file
diff --git a/UpToolLib/Tool/AppExtras.cs b/UpToolLib/Tool/AppExtras.cs
index 2d2771b..9246844 100644
--- a/UpToolLib/Tool/AppExtras.cs
+++ b/UpToolLib/Tool/AppExtras.cs
@@ -72,9 +72,9 @@ namespace UpToolLib.Tool
File.Delete(app.InfoPath);
if (File.Exists(Path.Combine(app.AppPath, "package.zip")))
File.Delete(Path.Combine(app.AppPath, "package.zip"));
- if (deleteAll || (Directory.Exists(app.DataPath) &&
- Directory.GetFiles(app.DataPath).Length + Directory.GetDirectories(app.DataPath).Length ==
- 0))
+ if (deleteAll || Directory.Exists(app.DataPath) &&
+ Directory.GetFiles(app.DataPath).Length + Directory.GetDirectories(app.DataPath).Length ==
+ 0)
Directory.Delete(app.AppPath, true);
}
diff --git a/UpToolLib/Tool/AppInstall.cs b/UpToolLib/Tool/AppInstall.cs
index 22d856e..c1060e7 100644
--- a/UpToolLib/Tool/AppInstall.cs
+++ b/UpToolLib/Tool/AppInstall.cs
@@ -1,6 +1,5 @@
using System;
using System.Diagnostics;
-using System.Linq;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
diff --git a/UpToolLib/Tool/RepoManagement.cs b/UpToolLib/Tool/RepoManagement.cs
index 2bf96d5..31c0791 100644
--- a/UpToolLib/Tool/RepoManagement.cs
+++ b/UpToolLib/Tool/RepoManagement.cs
@@ -4,7 +4,6 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Xml.Linq;
-using CC_Functions.Misc;
using UpToolLib.DataStructures;
namespace UpToolLib.Tool
@@ -69,7 +68,12 @@ namespace UpToolLib.Tool
{
// ignored
}
- tmpAppsList.Last().Add(new XElement("Platform", app.Element("Platform") == null || !new[]{GlobalVariables.Posix, GlobalVariables.Windows}.Contains(app.Element("Platform").Value) ? GlobalVariables.CurrentPlatform : app.Element("Platform").Value));
+ tmpAppsList.Last().Add(new XElement("Platform",
+ app.Element("Platform") == null ||
+ !new[] {GlobalVariables.Posix, GlobalVariables.Windows}.Contains(app.Element("Platform")
+ .Value)
+ ? GlobalVariables.CurrentPlatform
+ : app.Element("Platform").Value));
XElement app1 = app;
if (tmpAppsList.Count(a => a.Element("ID").Value == app1.Element("ID").Value) > 1)
tmpAppsList.Where(a => a.Element("ID").Value == app.Element("ID").Value).Reverse()
diff --git a/UpToolLib/UpdateCheck.cs b/UpToolLib/UpdateCheck.cs
index 12abafd..2d2d38e 100644
--- a/UpToolLib/UpdateCheck.cs
+++ b/UpToolLib/UpdateCheck.cs
@@ -17,12 +17,16 @@ namespace UpToolLib
}
set => _meta = value;
}
+
public static Version OnlineVersion => Version.Parse(Meta.Element("Version").Value);
public static Uri Installer => new Uri(Meta.Element("Installer").Value).TryUnshorten();
public static string InstallerHash => Meta.Element("InstallerHash").Value.ToUpper();
public static Uri App => new Uri(Meta.Element("File").Value).TryUnshorten();
public static string AppHash => Meta.Element("Hash").Value.ToUpper();
- public static void Reload() => Reload(XDocument.Load(PathTool.InfoXml).Element("meta").Element("UpdateSource").Value);
+
+ public static void Reload() =>
+ Reload(XDocument.Load(PathTool.InfoXml).Element("meta").Element("UpdateSource").Value);
+
public static void Reload(string source) => Meta = XDocument.Load(source).Element("meta");
}
}
\ No newline at end of file