mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-01 02:53:46 +12:00
Fixed download file name
This commit is contained in:
parent
d57e730baa
commit
71efc3990f
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue