mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 06:13:40 +01:00
Merge pull request #456 from daemitus/utility
This commit is contained in:
commit
9199adb261
44 changed files with 485 additions and 444 deletions
|
|
@ -272,7 +272,7 @@ namespace Dalamud.Plugin.Internal
|
|||
this.Manifest.Save(this.manifestFile);
|
||||
}
|
||||
|
||||
this.DalamudInterface = new DalamudPluginInterface(this.dalamud, this.pluginAssembly.GetName().Name, this.DllFile.FullName, reason);
|
||||
this.DalamudInterface = new DalamudPluginInterface(this.dalamud, this.pluginAssembly.GetName().Name, reason);
|
||||
|
||||
if (this.IsDev)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -17,6 +17,7 @@ using Dalamud.Game.Text;
|
|||
using Dalamud.Logging.Internal;
|
||||
using Dalamud.Plugin.Internal.Exceptions;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Utility;
|
||||
using HarmonyLib;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -359,16 +360,17 @@ namespace Dalamud.Plugin.Internal
|
|||
// ignored, since the plugin may be loaded already
|
||||
}
|
||||
|
||||
using var client = new WebClient();
|
||||
|
||||
var tempZip = new FileInfo(Path.GetTempFileName());
|
||||
|
||||
try
|
||||
{
|
||||
Log.Debug($"Downloading plugin to {tempZip} from {downloadUrl}");
|
||||
client.DownloadFile(downloadUrl, tempZip.FullName);
|
||||
using var client = new HttpClient();
|
||||
var response = client.GetAsync(downloadUrl).Result;
|
||||
using var fs = new FileStream(tempZip.FullName, FileMode.CreateNew);
|
||||
response.Content.CopyToAsync(fs).GetAwaiter().GetResult();
|
||||
}
|
||||
catch (WebException ex)
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Log.Error(ex, $"Download of plugin {repoManifest.Name} failed unexpectedly.");
|
||||
throw;
|
||||
|
|
@ -977,26 +979,21 @@ namespace Dalamud.Plugin.Internal
|
|||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "Enforced naming for special injected parameters")]
|
||||
private static void AssemblyLocationPatch(Assembly __instance, ref string __result)
|
||||
{
|
||||
// Assembly.GetExecutingAssembly can return this.
|
||||
// Check for it as a special case and find the plugin.
|
||||
if (__result.EndsWith("System.Private.CoreLib.dll", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (string.IsNullOrEmpty(__result))
|
||||
{
|
||||
foreach (var assemblyName in GetStackFrameAssemblyNames())
|
||||
{
|
||||
if (PluginLocations.TryGetValue(assemblyName, out var data))
|
||||
{
|
||||
__result = data.Location;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (string.IsNullOrEmpty(__result))
|
||||
{
|
||||
if (PluginLocations.TryGetValue(__instance.FullName, out var data))
|
||||
{
|
||||
__result = data.Location;
|
||||
}
|
||||
}
|
||||
|
||||
__result ??= string.Empty;
|
||||
|
||||
Log.Verbose($"Assembly.Location // {__instance.FullName} // {__result}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1009,26 +1006,21 @@ namespace Dalamud.Plugin.Internal
|
|||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "Enforced naming for special injected parameters")]
|
||||
private static void AssemblyCodeBasePatch(Assembly __instance, ref string __result)
|
||||
{
|
||||
// Assembly.GetExecutingAssembly can return this.
|
||||
// Check for it as a special case and find the plugin.
|
||||
if (__result.EndsWith("System.Private.CoreLib.dll"))
|
||||
if (string.IsNullOrEmpty(__result))
|
||||
{
|
||||
foreach (var assemblyName in GetStackFrameAssemblyNames())
|
||||
{
|
||||
if (PluginLocations.TryGetValue(assemblyName, out var data))
|
||||
{
|
||||
__result = data.Location;
|
||||
return;
|
||||
__result = data.CodeBase;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (string.IsNullOrEmpty(__result))
|
||||
{
|
||||
if (PluginLocations.TryGetValue(__instance.FullName, out var data))
|
||||
{
|
||||
__result = data.Location;
|
||||
}
|
||||
}
|
||||
|
||||
__result ??= string.Empty;
|
||||
|
||||
Log.Verbose($"Assembly.CodeBase // {__instance.FullName} // {__result}");
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetStackFrameAssemblyNames()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Logging.Internal;
|
||||
|
|
@ -74,11 +74,10 @@ namespace Dalamud.Plugin.Internal
|
|||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
using var client = new WebClient();
|
||||
|
||||
Log.Information($"Fetching repo: {this.PluginMasterUrl}");
|
||||
|
||||
var data = client.DownloadString(this.PluginMasterUrl);
|
||||
using var client = new HttpClient();
|
||||
using var response = client.GetAsync(this.PluginMasterUrl).Result;
|
||||
var data = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
var pluginMaster = JsonConvert.DeserializeObject<List<RemotePluginManifest>>(data);
|
||||
pluginMaster.Sort((pm1, pm2) => pm1.Name.CompareTo(pm2.Name));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue