mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
VRCX self updater 1
This commit is contained in:
@@ -299,7 +299,7 @@ namespace VRCX
|
||||
|
||||
public void DownloadVRCXUpdate(string url, string AppVersion)
|
||||
{
|
||||
var Location = Path.Combine(Program.BaseDirectory, "update.zip");
|
||||
var Location = Path.Combine(Program.AppDataDirectory, "update.exe");
|
||||
WebClient client = new WebClient();
|
||||
client.Headers.Add("user-agent", AppVersion);
|
||||
client.DownloadFile(new System.Uri(url), Location);
|
||||
@@ -316,7 +316,7 @@ namespace VRCX
|
||||
|
||||
public bool checkForUpdateZip()
|
||||
{
|
||||
if (File.Exists(Path.Combine(Program.BaseDirectory, "update.zip")))
|
||||
if (File.Exists(Path.Combine(Program.AppDataDirectory, "update.exe")))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace VRCX
|
||||
if (IsUpdate)
|
||||
{
|
||||
AssetBundleCacher.IsUpdate = true;
|
||||
DownloadTempLocation = Path.Combine(Program.BaseDirectory, "update.zip");
|
||||
DownloadTempLocation = Path.Combine(Program.AppDataDirectory, "update.exe");
|
||||
}
|
||||
client = new WebClient();
|
||||
client.Headers.Add("user-agent", AppVersion);
|
||||
|
||||
72
Update.cs
72
Update.cs
@@ -1,11 +1,10 @@
|
||||
// Copyright(c) 2019-2021 pypy. All rights reserved.
|
||||
// Copyright(c) 2019-2021 pypy. All rights reserved.
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VRCX
|
||||
@@ -13,67 +12,30 @@ namespace VRCX
|
||||
class Update
|
||||
{
|
||||
public static void Check()
|
||||
{
|
||||
if (File.Exists(Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe")))
|
||||
File.Delete(Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe"));
|
||||
if (File.Exists(Path.Combine(Program.AppDataDirectory, "update.exe")))
|
||||
Install();
|
||||
}
|
||||
|
||||
public static void Install()
|
||||
{
|
||||
try
|
||||
{
|
||||
var CurrentDirectory = new DirectoryInfo(Program.BaseDirectory);
|
||||
FileInfo[] Files = CurrentDirectory.GetFiles();
|
||||
foreach (FileInfo FileDetails in Files)
|
||||
{
|
||||
var FilePath = Path.Combine(Program.BaseDirectory, FileDetails.Name);
|
||||
if (FileDetails.Extension == ".old")
|
||||
File.Delete(FilePath);
|
||||
}
|
||||
var Location = Path.Combine(Program.BaseDirectory, "update.zip");
|
||||
if (File.Exists(Location))
|
||||
Install();
|
||||
if (!File.Exists(Path.Combine(Program.AppDataDirectory, "update.exe")))
|
||||
return;
|
||||
File.Move(Path.Combine(Program.AppDataDirectory, "update.exe"), Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe"));
|
||||
System.Diagnostics.Process VRCXProcess = new System.Diagnostics.Process();
|
||||
VRCXProcess.StartInfo.FileName = Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe");
|
||||
VRCXProcess.StartInfo.Arguments = "/S";
|
||||
VRCXProcess.Start();
|
||||
System.Environment.Exit(0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), "Update failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Install()
|
||||
{
|
||||
var Location = Path.Combine(Program.BaseDirectory, "update.zip");
|
||||
if (!File.Exists(Location))
|
||||
return;
|
||||
if (File.Exists(Path.Combine(Program.BaseDirectory, "VRCX.exe.old")))
|
||||
File.Delete(Path.Combine(Program.BaseDirectory, "VRCX.exe.old"));
|
||||
if (File.Exists(Path.Combine(Program.BaseDirectory, "VRCX.exe")))
|
||||
File.Move(Path.Combine(Program.BaseDirectory, "VRCX.exe"), Path.Combine(Program.BaseDirectory, "VRCX.exe.old"));
|
||||
var CurrentDirectory = new DirectoryInfo(Program.BaseDirectory);
|
||||
FileInfo[] Files = CurrentDirectory.GetFiles();
|
||||
foreach (FileInfo FileDetails in Files)
|
||||
{
|
||||
var FilePath = Path.Combine(Program.BaseDirectory, $"{FileDetails.Name}.old");
|
||||
if (FileDetails.Extension == ".dll")
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
File.Delete(FilePath);
|
||||
File.Move(Path.Combine(Program.BaseDirectory, FileDetails.Name), FilePath);
|
||||
}
|
||||
}
|
||||
using (ZipArchive archive = ZipFile.OpenRead(Location))
|
||||
{
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
var path = Path.Combine(Program.BaseDirectory, entry.FullName);
|
||||
if (entry.Name == "")
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
continue;
|
||||
}
|
||||
entry.ExtractToFile(path, true);
|
||||
}
|
||||
}
|
||||
File.Delete(Location);
|
||||
System.Diagnostics.Process VRCXProcess = new System.Diagnostics.Process();
|
||||
VRCXProcess.StartInfo.FileName = Path.Combine(Program.BaseDirectory, "VRCX.exe");
|
||||
VRCXProcess.StartInfo.UseShellExecute = false;
|
||||
VRCXProcess.Start();
|
||||
System.Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13234,8 +13234,8 @@ speechSynthesis.getVoices();
|
||||
$app.data.checkingForVRCXUpdate = false;
|
||||
|
||||
$app.data.branches = {
|
||||
Stable: { name: 'Stable', urlReleases: 'https://api.github.com/repos/pypy-vrc/VRCX/releases', urlLatest: 'https://api.github.com/repos/pypy-vrc/VRCX/releases/latest' },
|
||||
Beta: { name: 'Beta', urlReleases: 'https://api.github.com/repos/natsumi-sama/VRCX/releases', urlLatest: 'https://api.github.com/repos/natsumi-sama/VRCX/releases/latest' }
|
||||
Stable: { name: 'Stable', urlReleases: 'https://vrcx.pypy.moe/releases/pypy-vrc.json', urlLatest: 'https://vrcx.pypy.moe/releases/latest/pypy-vrc.json' },
|
||||
Beta: { name: 'Beta', urlReleases: 'https://vrcx.pypy.moe/releases/natsumi-sama.json', urlLatest: 'https://vrcx.pypy.moe/releases/latest/natsumi-sama.json' }
|
||||
};
|
||||
|
||||
$app.methods.showVRCXUpdateDialog = async function () {
|
||||
@@ -13320,25 +13320,26 @@ speechSynthesis.getVoices();
|
||||
json.published_at) {
|
||||
this.latestAppVersion = `${json.name} (${formatDate(json.published_at, 'YYYY-MM-DD HH24:MI:SS')})`;
|
||||
if (json.name > this.appVersion) {
|
||||
if ((json.assets[0].content_type !== 'application/x-zip-compressed') || (json.assets[0].state !== 'uploaded')) {
|
||||
for (var asset of json.assets) {
|
||||
if ((asset.content_type === 'application/octet-stream') && (asset.state === 'uploaded')) {
|
||||
var downloadUrl = asset.browser_download_url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!downloadUrl) {
|
||||
return;
|
||||
}
|
||||
this.notifyMenu('settings');
|
||||
var downloadUrl = json.assets[0].browser_download_url;
|
||||
var name = json.name;
|
||||
var type = 'Auto';
|
||||
if (this.autoUpdateVRCX === 'Notify') {
|
||||
this.showVRCXUpdateDialog();
|
||||
} else if (this.autoUpdateVRCX === 'Auto Download') {
|
||||
if (downloadUrl) {
|
||||
var autoInstall = false;
|
||||
this.downloadVRCXUpdate(downloadUrl, name, type, autoInstall);
|
||||
}
|
||||
var autoInstall = false;
|
||||
this.downloadVRCXUpdate(downloadUrl, name, type, autoInstall);
|
||||
} else if (this.autoUpdateVRCX === 'Auto Install') {
|
||||
if (downloadUrl) {
|
||||
var autoInstall = true;
|
||||
this.downloadVRCXUpdate(downloadUrl, name, type, autoInstall);
|
||||
}
|
||||
var autoInstall = true;
|
||||
this.downloadVRCXUpdate(downloadUrl, name, type, autoInstall);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user