Possibly fixed

This commit is contained in:
CreepyCrafter24 2019-11-09 21:28:41 +01:00
parent fdea54711e
commit 66276643c5
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<meta>
<Version>11</Version>
<File>https://github.com/CreepyCrafter24/UpTool2/releases/download/v1.9/UpTool2.exe</File>
<Hash>524A3E5F7EAF3EF147B4C2A614A15FEB2F059CDE0A23E1626E54E5CF1AF2FEF3</Hash>
<Version>12</Version>
<File>https://github.com/CreepyCrafter24/UpTool2/releases/download/v1.10/UpTool2.exe</File>
<Hash>27139FF2797C25C04100F1BF587C4F10BB2C1B7C837052906414F831F2B8CB10</Hash>
</meta>

View File

@ -12,6 +12,7 @@ using System.Windows.Forms;
using System.Xml.Linq;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;
namespace UpTool2
{
@ -80,13 +81,16 @@ namespace UpTool2
Directory.CreateDirectory(dir + @"\Apps");
string xml = dir + @"\info.xml";
string metaXml = "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml";
if (!File.Exists(xml))
if ((!File.Exists(xml)) || XDocument.Load(xml).Element("meta") == null || XDocument.Load(xml).Element("meta").Element("Repos") == null || XDocument.Load(xml).Element("meta").Element("Repos").Elements("Repo").Count() == 0)
new XElement("meta", new XElement("Version", 0), new XElement("Repos", new XElement("Repo", new XElement("Name", "UpTool2 official Repo"), new XElement("Link", "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Repo.xml"))), new XElement("LocalRepo")).Save(xml);
else
{
//Update old app repo to in-git repo
XDocument x = XDocument.Load(xml);
x.Element("meta").Element("Repos").Elements("Repo").Select(s => s.Element("Link")).Where(s => s.Value == "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml").ToList().ForEach(s => s.Value = "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Repo.xml");
XElement meta = x.Element("meta");
XElement repos = meta.Element("Repos");
IEnumerable<XElement> reposa = repos.Elements("Repo");
reposa.Select(s => s.Element("Link")).Where(s => s.Value == "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml").ToList().ForEach(s => s.Value = "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Repo.xml");
x.Save(xml);
}
online = Ping(metaXml);