From 71efc3990fbcff8869bf9cab0e2c47cdcb298dbb Mon Sep 17 00:00:00 2001 From: Usman Shafiq Date: Sun, 12 Jun 2022 02:35:56 -0400 Subject: [PATCH] Fixed download file name --- VRCMelonAssistant/Classes/InstallHandlers.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/VRCMelonAssistant/Classes/InstallHandlers.cs b/VRCMelonAssistant/Classes/InstallHandlers.cs index d2d3f86..f173080 100644 --- a/VRCMelonAssistant/Classes/InstallHandlers.cs +++ b/VRCMelonAssistant/Classes/InstallHandlers.cs @@ -90,19 +90,25 @@ namespace VRCMelonAssistant if (mod.installedFilePath != null) File.Delete(mod.installedFilePath); + - var modUri = new Uri(downloadLink); - var targetFilePath = Path.Combine(App.VRChatInstallDirectory, mod.versions[0].IsPlugin ? "Plugins" : "Mods", - mod.versions[0].IsBroken ? "Broken" : "", modUri.Segments.Last()); + string targetFilePath = ""; - Directory.CreateDirectory(Path.GetDirectoryName(targetFilePath)); - - using (Stream stream = await DownloadFileToMemory(downloadLink)) + using (var resp = await Http.HttpClient.GetAsync(downloadLink)) { + var stream = new MemoryStream(); + await resp.Content.CopyToAsync(stream); + stream.Position = 0; + + targetFilePath = Path.Combine(App.VRChatInstallDirectory, mod.versions[0].IsPlugin ? "Plugins" : "Mods", + mod.versions[0].IsBroken ? "Broken" : "", resp.RequestMessage.RequestUri.Segments.Last()); + + Directory.CreateDirectory(Path.GetDirectoryName(targetFilePath)); + using var targetFile = File.OpenWrite(targetFilePath); await stream.CopyToAsync(targetFile); } - + mod.ListItem.IsInstalled = true; mod.installedFilePath = targetFilePath; mod.ListItem.InstalledVersion = mod.versions[0].modVersion;