Maybe fix
This commit is contained in:
parent
af1f9fbfea
commit
46a9bf099b
|
@ -55,7 +55,9 @@ namespace UpTool2
|
||||||
#endif
|
#endif
|
||||||
hasHandle = true;
|
hasHandle = true;
|
||||||
}
|
}
|
||||||
FixXML(PathTool.infoXML);
|
if (!Directory.Exists(PathTool.dir))
|
||||||
|
Directory.CreateDirectory(PathTool.dir);
|
||||||
|
FixXML();
|
||||||
string metaXML = XDocument.Load(PathTool.infoXML).Element("meta").Element("UpdateSource").Value;
|
string metaXML = XDocument.Load(PathTool.infoXML).Element("meta").Element("UpdateSource").Value;
|
||||||
online = Ping(metaXML);
|
online = Ping(metaXML);
|
||||||
|
|
||||||
|
@ -127,31 +129,31 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
||||||
splash.BringToFront();
|
splash.BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FixXML(string xml, bool throwOnError = false)
|
public static void FixXML(bool throwOnError = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ((!File.Exists(xml)) || XDocument.Load(xml).Element("meta") == null)
|
if ((!File.Exists(PathTool.infoXML)) || XDocument.Load(PathTool.infoXML).Element("meta") == null)
|
||||||
new XElement("meta").Save(xml);
|
new XElement("meta").Save(PathTool.infoXML);
|
||||||
XDocument x = XDocument.Load(xml);
|
XDocument x = XDocument.Load(PathTool.infoXML);
|
||||||
XElement meta = x.Element("meta");
|
XElement meta = x.Element("meta");
|
||||||
if (meta.Element("UpdateSource") == null)
|
if (meta.Element("UpdateSource") == null)
|
||||||
meta.Add(new XElement("UpdateSource"));
|
meta.Add(new XElement("UpdateSource"));
|
||||||
if (new string[] { null, "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml",
|
if (new string[] { "", "https://raw.githubusercontent.com/CreepyCrafter24/UpTool2/master/Meta.xml",
|
||||||
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Meta.xml" }
|
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Meta.xml" }
|
||||||
.Contains(meta.Element("UpdateSource").Value))
|
.Contains(meta.Element("UpdateSource").Value))
|
||||||
meta.Element("UpdateSource").Value = "https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Meta.xml";
|
meta.Element("UpdateSource").Value = "https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Meta.xml";
|
||||||
if (meta.Element("Repos") == null)
|
if (meta.Element("Repos") == null)
|
||||||
meta.Add(new XElement("Repos"));
|
meta.Add(new XElement("Repos"));
|
||||||
if (meta.Element("Repos").Elements("Repo").Count() == 0)
|
if (meta.Element("Repos").Elements("Repo").Count() == 0)
|
||||||
meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"), new XElement("Link", "https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Meta.xml")));
|
meta.Element("Repos").Add(new XElement("Repo", new XElement("Name", "UpTool2 official Repo"), new XElement("Link", "https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml")));
|
||||||
meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link"))
|
meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link"))
|
||||||
.Where(s => new string[] { null, "https://github.com/JFronny/UpTool2/releases/download/Repo/Repo.xml",
|
.Where(s => new string[] { null, "https://github.com/JFronny/UpTool2/releases/download/Repo/Repo.xml",
|
||||||
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Repo.xml"}.Contains(s.Value))
|
"https://raw.githubusercontent.com/JFronny/UpTool2/master/Repo.xml"}.Contains(s.Value))
|
||||||
.ToList().ForEach(s => s.Value = "https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml");
|
.ToList().ForEach(s => s.Value = "https://gist.githubusercontent.com/JFronny/f1ccbba3d8a2f5862592bb29fdb612c4/raw/Repo.xml");
|
||||||
if (meta.Element("LocalRepo") == null)
|
if (meta.Element("LocalRepo") == null)
|
||||||
meta.Add(new XElement("LocalRepo"));
|
meta.Add(new XElement("LocalRepo"));
|
||||||
x.Save(xml);
|
x.Save(PathTool.infoXML);
|
||||||
}
|
}
|
||||||
catch (XmlException)
|
catch (XmlException)
|
||||||
{
|
{
|
||||||
|
@ -159,8 +161,9 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
||||||
throw;
|
throw;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
File.Delete(xml);
|
MessageBox.Show("Something went wrong while trying to parse XML. Retrying...");
|
||||||
FixXML(xml);
|
File.Delete(PathTool.infoXML);
|
||||||
|
FixXML();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace UpTool2
|
||||||
public SettingsForms()
|
public SettingsForms()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Program.FixXML(PathTool.infoXML);
|
Program.FixXML();
|
||||||
doc = XDocument.Load(PathTool.infoXML);
|
doc = XDocument.Load(PathTool.infoXML);
|
||||||
meta = doc.Element("meta");
|
meta = doc.Element("meta");
|
||||||
repos = meta.Element("Repos");
|
repos = meta.Element("Repos");
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace UpTool2.Tool
|
||||||
{
|
{
|
||||||
public static void fetchRepos()
|
public static void fetchRepos()
|
||||||
{
|
{
|
||||||
Program.FixXML(PathTool.infoXML);
|
Program.FixXML();
|
||||||
XElement meta = XDocument.Load(PathTool.infoXML).Element("meta");
|
XElement meta = XDocument.Load(PathTool.infoXML).Element("meta");
|
||||||
List<XElement> tmp_apps_list = new List<XElement>();
|
List<XElement> tmp_apps_list = new List<XElement>();
|
||||||
List<string> repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).Distinct().ToList();
|
List<string> repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Element("Link").Value).Distinct().ToList();
|
||||||
|
|
Reference in New Issue
Block a user