Skip to content

Commit

Permalink
Add additional installer logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SenkyDragon committed Dec 27, 2023
1 parent cdbb0a5 commit f3f9637
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
23 changes: 18 additions & 5 deletions com.vrcfury.installer/VRCFuryInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ await DisplayDialog(

private static async Task InstallUnsafe() {
if (HasLocalDirectoryVrcfPackage()) {
Debug.LogWarning("VRCF Installer is not running, because you have a vrcfury package installed in development mode (local directory)");
Log("Not running, because you have a vrcfury package installed in development mode (local directory)");
return;
}

Log("Starting ...");

var restarting = await InMainThread(() => {
var changed = false;
changed |= Delete("Packages/com.vrcfury.vrcfury.tgz");
Expand All @@ -52,6 +54,7 @@ private static async Task InstallUnsafe() {
}

var url = "https://vrcfury.com/downloadRawZip";
Log("Downloading ...");
var tempFile = await InMainThread(FileUtil.GetUniqueTempPathInProject) + ".zip";
try {
using (var response = await HttpClient.GetAsync(url)) {
Expand All @@ -64,6 +67,7 @@ private static async Task InstallUnsafe() {
throw new Exception($"Failed to download {url}\n{e.Message}", e);
}

Log("Extracting ...");
var tmpDir = await InMainThread(FileUtil.GetUniqueTempPathInProject);
using (var stream = File.OpenRead(tempFile)) {
using (var archive = new ZipArchive(stream)) {
Expand All @@ -85,7 +89,7 @@ await InMainThread(() => {
var appRootDir = Path.GetDirectoryName(Application.dataPath);
Directory.CreateDirectory(appRootDir + "/Temp/vrcfInstalling");
Debug.Log($"Moving {tmpDir} to Packages/com.vrcfury.vrcfury");
Log($"Moving {tmpDir} to Packages/com.vrcfury.vrcfury");
Directory.Move(tmpDir, "Packages/com.vrcfury.vrcfury");
CleanManifest(false);
Expand All @@ -103,6 +107,7 @@ await InMainThread(() => {
}

private static void RefreshPackages() {
Log("Re-resolving packages ...");
MethodInfo method = typeof(Client).GetMethod("Resolve",
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public,
null,
Expand All @@ -124,7 +129,11 @@ private static bool CleanManifest(bool mainOnly) {
if (!File.Exists(manifestPath)) return false;
var lines = File.ReadLines(manifestPath).ToArray();
bool ShouldRemoveLine(string line) {
return line.Contains("com.vrcfury.") && (!mainOnly || line.Contains("com.vrcfury.vrcfury"));
var remove = line.Contains("com.vrcfury.") && (!mainOnly || line.Contains("com.vrcfury.vrcfury"));
if (remove) {
Log($"Removing manifest line: {line}");
}
return remove;
}
var linesToKeep = lines.Where(l => !ShouldRemoveLine(l)).ToArray();
if (lines.Length == linesToKeep.Length) return false;
Expand All @@ -138,12 +147,12 @@ bool ShouldRemoveLine(string line) {
private static bool Delete(string path) {
if (string.IsNullOrWhiteSpace(path)) return false;
if (Directory.Exists(path)) {
Debug.Log("Deleting directory: " + path);
Log("Deleting directory: " + path);
Directory.Delete(path, true);
return true;
}
if (File.Exists(path)) {
Debug.Log("Deleting file: " + path);
Log("Deleting file: " + path);
File.Delete(path);
return true;
}
Expand Down Expand Up @@ -177,4 +186,8 @@ void Callback() {

return promise.Task;
}

private static void Log(string message) {
Debug.Log($"VRCFury Installer > {message}");
}
}
5 changes: 4 additions & 1 deletion com.vrcfury.installer/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "com.vrcfury.installer",
"displayName": "VRCFury Installer",
"version": "0.0.0"
"version": "0.0.0",
"author": {
"name": "VRCFury"
}
}

0 comments on commit f3f9637

Please sign in to comment.