Fixes, semantic Versions for apps
This commit is contained in:
parent
efb9262c2e
commit
28a5d3c3f7
@ -1,8 +1,6 @@
|
|||||||
More Icons for Apps
|
More Icons for Apps
|
||||||
More apps: Laptop Sim (when done)
|
More apps: Laptop Sim (when done)
|
||||||
Automatically push Meta.xml changes after building
|
Automatically push Meta.xml changes after building
|
||||||
Support semantic versioning for app updates (App object versions will have to be converted)
|
|
||||||
Use binary version for Updates
|
|
||||||
Less code in MainForm.cs!
|
Less code in MainForm.cs!
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ namespace UpTool2
|
|||||||
{
|
{
|
||||||
public string name;
|
public string name;
|
||||||
public string description;
|
public string description;
|
||||||
public int version;
|
public Version version;
|
||||||
public string file;
|
public string file;
|
||||||
public bool local;
|
public bool local;
|
||||||
public string hash;
|
public string hash;
|
||||||
@ -21,7 +21,7 @@ namespace UpTool2
|
|||||||
public bool runnable;
|
public bool runnable;
|
||||||
public string mainFile;
|
public string mainFile;
|
||||||
|
|
||||||
public App(string name, string description, int version, string file, bool local, string hash, Guid iD, Color color, Image icon, bool runnable, string mainFile)
|
public App(string name, string description, Version version, string file, bool local, string hash, Guid iD, Color color, Image icon, bool runnable, string mainFile)
|
||||||
{
|
{
|
||||||
this.name = name ?? throw new ArgumentNullException(nameof(name));
|
this.name = name ?? throw new ArgumentNullException(nameof(name));
|
||||||
this.description = description ?? throw new ArgumentNullException(nameof(description));
|
this.description = description ?? throw new ArgumentNullException(nameof(description));
|
||||||
@ -34,24 +34,18 @@ namespace UpTool2
|
|||||||
this.icon = icon ?? throw new ArgumentNullException(nameof(icon));
|
this.icon = icon ?? throw new ArgumentNullException(nameof(icon));
|
||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
this.mainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
|
this.mainFile = mainFile ?? throw new ArgumentNullException(nameof(mainFile));
|
||||||
#if DEBUG
|
|
||||||
Console.WriteLine(";" + mainFile + ";" + this.mainFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status status
|
public Status status
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\UpTool2";
|
string xml = GlobalVariables.getInfoPath(ID);
|
||||||
string xml = dir + @"\Apps\" + ID.ToString() + @"\info.xml";
|
|
||||||
if (File.Exists(xml))
|
if (File.Exists(xml))
|
||||||
{
|
{
|
||||||
if (int.Parse(XDocument.Load(xml).Element("app").Element("Version").Value) < version)
|
if (Version.TryParse(XDocument.Load(xml).Element("app").Element("Version").Value, out Version ver) && ver >= version)
|
||||||
return Status.Updatable;
|
return local ? (Status.Installed | Status.Local) : Status.Installed;
|
||||||
else
|
else
|
||||||
{
|
return Status.Installed | Status.Updatable;
|
||||||
return local ? Status.Installed | Status.Local : Status.Installed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Status.Not_Installed;
|
return Status.Not_Installed;
|
||||||
|
@ -19,13 +19,15 @@ namespace UpTool2
|
|||||||
{
|
{
|
||||||
string app = "";
|
string app = "";
|
||||||
string tmp = "";
|
string tmp = "";
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
app = appI.appPath;
|
app = appI.appPath;
|
||||||
tmp = GlobalVariables.dir + @"\tmp";
|
tmp = GlobalVariables.dir + @"\tmp";
|
||||||
if (Directory.Exists(""))
|
if (Directory.Exists(tmp))
|
||||||
Directory.Delete("", true);
|
Directory.Delete(tmp, true);
|
||||||
Directory.CreateDirectory("");
|
Directory.CreateDirectory(tmp);
|
||||||
if (Directory.Exists(app))
|
if (Directory.Exists(app))
|
||||||
Directory.Delete(app, true);
|
Directory.Delete(app, true);
|
||||||
Directory.CreateDirectory(app);
|
Directory.CreateDirectory(app);
|
||||||
@ -38,6 +40,7 @@ namespace UpTool2
|
|||||||
throw new Exception("The hash is not equal to the one stored in the repo:\r\nPackage: " + pkghash + "\r\nOnline: " + appI.hash.ToUpper());
|
throw new Exception("The hash is not equal to the one stored in the repo:\r\nPackage: " + pkghash + "\r\nOnline: " + appI.hash.ToUpper());
|
||||||
}
|
}
|
||||||
completeInstall(appI);
|
completeInstall(appI);
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -47,9 +50,12 @@ namespace UpTool2
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
if (tmp != "" && Directory.Exists(tmp))
|
if (tmp != "" && Directory.Exists(tmp))
|
||||||
Directory.Delete(tmp, true);
|
Directory.Delete(tmp, true);
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void installZip(string zipPath, App meta)
|
public static void installZip(string zipPath, App meta)
|
||||||
@ -82,7 +88,7 @@ namespace UpTool2
|
|||||||
|
|
||||||
static void completeInstall(App app) => completeInstall(app.appPath, app.name, app.description, app.version, app.mainFile);
|
static void completeInstall(App app) => completeInstall(app.appPath, app.name, app.description, app.version, app.mainFile);
|
||||||
|
|
||||||
static void completeInstall(string appPath, string name, string description, int version, string mainFile)
|
static void completeInstall(string appPath, string name, string description, Version version, string mainFile)
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
|
@ -18,5 +18,6 @@ namespace UpTool2
|
|||||||
public static string getInfoPath(Guid app) => getAppPath(app) + "\\info.xml";
|
public static string getInfoPath(Guid app) => getAppPath(app) + "\\info.xml";
|
||||||
public static bool relE = true;
|
public static bool relE = true;
|
||||||
public static Action reloadElements;
|
public static Action reloadElements;
|
||||||
|
public static Version minimumVer => Version.Parse("0.0.0.0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using UpTool2.Properties;
|
using UpTool2.Properties;
|
||||||
using System.Xml.Linq;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using Microsoft.VisualBasic;
|
using Microsoft.VisualBasic;
|
||||||
|
#if DEBUG
|
||||||
|
using System.Threading;
|
||||||
|
using System.Linq;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
@ -63,7 +66,7 @@ namespace UpTool2
|
|||||||
Guid ID = Guid.NewGuid();
|
Guid ID = Guid.NewGuid();
|
||||||
while (GlobalVariables.apps.ContainsKey(ID) || Directory.Exists(GlobalVariables.getAppPath(ID)))
|
while (GlobalVariables.apps.ContainsKey(ID) || Directory.Exists(GlobalVariables.getAppPath(ID)))
|
||||||
ID = Guid.NewGuid();
|
ID = Guid.NewGuid();
|
||||||
App appI = new App(Interaction.InputBox("Name:"), "Locally installed package, removal only", -1, "", true, "", ID, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
App appI = new App(Interaction.InputBox("Name:"), "Locally installed package, removal only", GlobalVariables.minimumVer, "", true, "", ID, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
||||||
AppInstall.installZip(searchPackageDialog.FileName, appI);
|
AppInstall.installZip(searchPackageDialog.FileName, appI);
|
||||||
}
|
}
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
@ -111,6 +114,7 @@ namespace UpTool2
|
|||||||
sidebarIcon.Size = new Size(70, 70);
|
sidebarIcon.Size = new Size(70, 70);
|
||||||
sidebarIcon.BackgroundImage = app.icon;
|
sidebarIcon.BackgroundImage = app.icon;
|
||||||
sidebarIcon.BackgroundImageLayout = ImageLayout.Stretch;
|
sidebarIcon.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
bool updatable = (!app.local) && ((app.status & Status.Updatable) == Status.Updatable);
|
||||||
sidebarIcon.Click += (object sender, EventArgs e) =>
|
sidebarIcon.Click += (object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
infoPanel_Title.Text = app.name;
|
infoPanel_Title.Text = app.name;
|
||||||
@ -121,12 +125,11 @@ namespace UpTool2
|
|||||||
action_remove.Tag = app;
|
action_remove.Tag = app;
|
||||||
action_remove.Enabled = Directory.Exists(app.appPath);
|
action_remove.Enabled = Directory.Exists(app.appPath);
|
||||||
action_update.Tag = app;
|
action_update.Tag = app;
|
||||||
string ver = XDocument.Load(app.infoPath).Element("app").Element("Version").Value;
|
action_update.Enabled = updatable;
|
||||||
action_update.Enabled = (!app.local) && File.Exists(app.infoPath) && int.Parse(ver) < app.version;
|
|
||||||
action_run.Tag = app;
|
action_run.Tag = app;
|
||||||
action_run.Enabled = (!app.local) && app.runnable && Directory.Exists(app.appPath);
|
action_run.Enabled = (!app.local) && app.runnable && Directory.Exists(app.appPath);
|
||||||
};
|
};
|
||||||
if ((!app.local) && File.Exists(app.infoPath) && int.Parse(XDocument.Load(app.infoPath).Element("app").Element("Version").Value) < app.version)
|
if (updatable)
|
||||||
availableUpdates++;
|
availableUpdates++;
|
||||||
toolTip.SetToolTip(sidebarIcon, app.name);
|
toolTip.SetToolTip(sidebarIcon, app.name);
|
||||||
sidebarPanel.Controls.Add(sidebarIcon);
|
sidebarPanel.Controls.Add(sidebarIcon);
|
||||||
@ -185,7 +188,7 @@ namespace UpTool2
|
|||||||
{
|
{
|
||||||
searchBox.Text = "!DEBUG:PRINT";
|
searchBox.Text = "!DEBUG:PRINT";
|
||||||
string _tmp_file = Path.GetTempFileName();
|
string _tmp_file = Path.GetTempFileName();
|
||||||
File.WriteAllText(_tmp_file, string.Join("\r\n\r\n", apps.Select(app => app.Value).Select(app => app.ToString()).ToArray()));
|
File.WriteAllText(_tmp_file, string.Join("\r\n\r\n", GlobalVariables.apps.Values.Select(app => app.ToString()).ToArray()));
|
||||||
new Thread(() => {
|
new Thread(() => {
|
||||||
Process.Start("notepad", _tmp_file).WaitForExit();
|
Process.Start("notepad", _tmp_file).WaitForExit();
|
||||||
File.Delete(_tmp_file);
|
File.Delete(_tmp_file);
|
||||||
|
@ -146,7 +146,7 @@ namespace UpTool2
|
|||||||
if (int.TryParse(ver, out int version))
|
if (int.TryParse(ver, out int version))
|
||||||
updatable = int.Parse(XDocument.Load(xml).Element("meta").Element("Version").Value) < version;
|
updatable = int.Parse(XDocument.Load(xml).Element("meta").Element("Version").Value) < version;
|
||||||
else
|
else
|
||||||
updatable = Assembly.GetExecutingAssembly().GetName().Version.CompareTo(Version.Parse(ver)) < 0;
|
updatable = Assembly.GetExecutingAssembly().GetName().Version < Version.Parse(ver);
|
||||||
if (updatable)
|
if (updatable)
|
||||||
{
|
{
|
||||||
using (DownloadDialog dlg = new DownloadDialog(meta.Element("File").Value, dir + @"\update.tmp"))
|
using (DownloadDialog dlg = new DownloadDialog(meta.Element("File").Value, dir + @"\update.tmp"))
|
||||||
|
@ -37,7 +37,7 @@ namespace UpTool2
|
|||||||
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value));
|
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value));
|
||||||
XElement[] tmp_apparray = repo.Element("repo").Elements("app").Where(app => tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Count() == 0 ||
|
XElement[] tmp_apparray = repo.Element("repo").Elements("app").Where(app => tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Count() == 0 ||
|
||||||
tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value)
|
tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value)
|
||||||
.Where(a => int.Parse(a.Element("Version").Value) >= int.Parse(app.Element("Version").Value)).Count() == 0).ToArray()
|
.Where(a => a.Element("Version").getVer() >= app.Element("Version").getVer()).Count() == 0).ToArray()
|
||||||
.Concat(repo.Element("repo").Elements("applink").Select(s => XDocument.Load(s.Value).Element("app"))).ToArray();
|
.Concat(repo.Element("repo").Elements("applink").Select(s => XDocument.Load(s.Value).Element("app"))).ToArray();
|
||||||
for (int i1 = 0; i1 < tmp_apparray.Length; i1++)
|
for (int i1 = 0; i1 < tmp_apparray.Length; i1++)
|
||||||
{
|
{
|
||||||
@ -108,6 +108,8 @@ namespace UpTool2
|
|||||||
meta.Save(xml);
|
meta.Save(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Version getVer(this XElement el) => int.TryParse(el.Value, out int i) ? new Version(0, 0, 0, i) : Version.Parse(el.Value);
|
||||||
|
|
||||||
public static void getReposFromDisk()
|
public static void getReposFromDisk()
|
||||||
{
|
{
|
||||||
GlobalVariables.apps.Clear();
|
GlobalVariables.apps.Clear();
|
||||||
@ -117,10 +119,12 @@ namespace UpTool2
|
|||||||
Guid id = Guid.Parse(app.Element("ID").Value);
|
Guid id = Guid.Parse(app.Element("ID").Value);
|
||||||
string locInPath = GlobalVariables.getInfoPath(id);
|
string locInPath = GlobalVariables.getInfoPath(id);
|
||||||
XElement locIn = File.Exists(locInPath) ? XDocument.Load(locInPath).Element("app") : app;
|
XElement locIn = File.Exists(locInPath) ? XDocument.Load(locInPath).Element("app") : app;
|
||||||
|
if (int.TryParse(app.Element("Version").Value, out int iputareallylongnameheresoiwillnotuseitlaterbyaccident))
|
||||||
|
app.Element("Version").Value = GlobalVariables.minimumVer.ToString();
|
||||||
GlobalVariables.apps.Add(id, new App(
|
GlobalVariables.apps.Add(id, new App(
|
||||||
name: locIn.Element("Name").Value,
|
name: locIn.Element("Name").Value,
|
||||||
description: locIn.Element("Description").Value,
|
description: locIn.Element("Description").Value,
|
||||||
version: int.Parse(app.Element("Version").Value),
|
version: Version.Parse(app.Element("Version").Value),
|
||||||
file: app.Element("File").Value,
|
file: app.Element("File").Value,
|
||||||
local: false,
|
local: false,
|
||||||
hash: app.Element("Hash").Value,
|
hash: app.Element("Hash").Value,
|
||||||
@ -132,7 +136,7 @@ namespace UpTool2
|
|||||||
));
|
));
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.WriteLine(locIn.Element("MainFile") == null ? "NULL" : locIn.Element("MainFile").Value);
|
Console.WriteLine(locIn.Element("MainFile") == null ? "NULL" : locIn.Element("MainFile").Value);
|
||||||
Console.WriteLine(apps[id].mainFile);
|
Console.WriteLine(GlobalVariables.apps[id].mainFile);
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
Directory.GetDirectories(GlobalVariables.dir + @"\Apps\").Where(s => !GlobalVariables.apps.ContainsKey(Guid.Parse(Path.GetFileName(s)))).ToList().ForEach(s =>
|
Directory.GetDirectories(GlobalVariables.dir + @"\Apps\").Where(s => !GlobalVariables.apps.ContainsKey(Guid.Parse(Path.GetFileName(s)))).ToList().ForEach(s =>
|
||||||
@ -141,7 +145,7 @@ namespace UpTool2
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
XElement data = XDocument.Load(GlobalVariables.getInfoPath(tmp)).Element("app");
|
XElement data = XDocument.Load(GlobalVariables.getInfoPath(tmp)).Element("app");
|
||||||
GlobalVariables.apps.Add(tmp, new App("(local) " + data.Element("Name").Value, data.Element("Description").Value, -1, "", true, "", tmp, Color.Red, Resources.C_64.ToBitmap(), data.Element("MainFile") != null, data.Element("MainFile") == null ? "" : data.Element("MainFile").Value));
|
GlobalVariables.apps.Add(tmp, new App("(local) " + data.Element("Name").Value, data.Element("Description").Value, GlobalVariables.minimumVer, "", true, "", tmp, Color.Red, Resources.C_64.ToBitmap(), data.Element("MainFile") != null, data.Element("MainFile") == null ? "" : data.Element("MainFile").Value));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user