Remove repo link unshortening, noticably reducing load time (way less requests have to be made)

This commit is contained in:
JFronny 2020-09-10 20:05:44 +02:00
parent 5e31ff3b45
commit f38a0e054d
4 changed files with 8 additions and 28 deletions

View File

@ -24,7 +24,7 @@ namespace UpToolLib
catch (AbandonedMutexException)
{
#if DEBUG
Debug.WriteLine("Mutex abandoned");
System.Diagnostics.Debug.WriteLine("Mutex abandoned");
#endif
_hasHandle = true;
}

View File

@ -4,7 +4,7 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using CC_Functions.Misc;
//using CC_Functions.Misc;
using UpToolLib.DataStructures;
namespace UpToolLib.Tool
@ -28,7 +28,7 @@ namespace UpToolLib.Tool
#endif
ExternalFunctionalityManager.Instance.Log($"[{i + 1}] Loading {repArr[i]}");
status = $"Loading {repArr[i]}";
XDocument repo = XDocument.Load(new Uri(repArr[i]).TryUnshorten().AbsoluteUri);
XDocument repo = XDocument.Load(new Uri(repArr[i]).AbsoluteUri);
status = $"Extracting repolinks";
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value)
.Where(s => !repArr.Contains(s)));
@ -43,7 +43,7 @@ namespace UpToolLib.Tool
{
ExternalFunctionalityManager.Instance.Log($"- Loading {s.Value}");
status = $"Fetching app data tag: {s.Value}";
XElement ret = XDocument.Load(new Uri(s.Value).TryUnshorten().AbsoluteUri)
XElement ret = XDocument.Load(new Uri(s.Value).AbsoluteUri)
.Element("app");
return ret;
}))
@ -60,7 +60,7 @@ namespace UpToolLib.Tool
new XElement("Description", app.Element("Description").Value),
new XElement("Version", app.Element("Version").Value),
new XElement("ID", app.Element("ID").Value),
new XElement("File", new Uri(app.Element("File").Value).Unshorten().ToString()),
new XElement("File", new Uri(app.Element("File").Value).ToString()),
new XElement("Hash", app.Element("Hash").Value)
));
if (app.Element("MainFile") != null)
@ -71,7 +71,7 @@ namespace UpToolLib.Tool
tmpAppsList.Last()
.Add(new XElement("Icon",
ExternalFunctionalityManager.Instance.FetchImageB64(
new Uri(app.Element("Icon").Value).TryUnshorten())));
new Uri(app.Element("Icon").Value))));
}
catch
{

View File

@ -1,20 +0,0 @@
using System;
using CC_Functions.Misc;
namespace UpToolLib.Tool
{
public static class TryUnshortenExt
{
public static Uri TryUnshorten(this Uri self)
{
try
{
return self.Unshorten();
}
catch
{
return self;
}
}
}
}

View File

@ -19,9 +19,9 @@ namespace UpToolLib
}
public static Version OnlineVersion => Version.Parse(Meta.Element("Version").Value);
public static Uri Installer => new Uri(Meta.Element("Installer").Value).TryUnshorten();
public static Uri Installer => new Uri(Meta.Element("Installer").Value);
public static string InstallerHash => Meta.Element("InstallerHash").Value.ToUpper();
public static Uri App => new Uri(Meta.Element("File").Value).TryUnshorten();
public static Uri App => new Uri(Meta.Element("File").Value);
public static string AppHash => Meta.Element("Hash").Value.ToUpper();
public static void Reload() =>