mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-21 12:53:18 +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)
|
if (mod.installedFilePath != null)
|
||||||
File.Delete(mod.installedFilePath);
|
File.Delete(mod.installedFilePath);
|
||||||
|
|
||||||
|
|
||||||
var modUri = new Uri(downloadLink);
|
string targetFilePath = "";
|
||||||
var targetFilePath = Path.Combine(App.VRChatInstallDirectory, mod.versions[0].IsPlugin ? "Plugins" : "Mods",
|
|
||||||
mod.versions[0].IsBroken ? "Broken" : "", modUri.Segments.Last());
|
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(targetFilePath));
|
using (var resp = await Http.HttpClient.GetAsync(downloadLink))
|
||||||
|
|
||||||
using (Stream stream = await DownloadFileToMemory(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);
|
using var targetFile = File.OpenWrite(targetFilePath);
|
||||||
await stream.CopyToAsync(targetFile);
|
await stream.CopyToAsync(targetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
mod.ListItem.IsInstalled = true;
|
mod.ListItem.IsInstalled = true;
|
||||||
mod.installedFilePath = targetFilePath;
|
mod.installedFilePath = targetFilePath;
|
||||||
mod.ListItem.InstalledVersion = mod.versions[0].modVersion;
|
mod.ListItem.InstalledVersion = mod.versions[0].modVersion;
|
||||||
|
|
Loading…
Reference in a new issue