Fixed download file name

This commit is contained in:
Usman Shafiq 2022-06-12 02:35:56 -04:00
parent d57e730baa
commit 71efc3990f

View file

@ -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;