From f721e71165e7a7b57788b82852732614869d1059 Mon Sep 17 00:00:00 2001 From: ComputerElite <71177995+ComputerElite@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:53:40 +0100 Subject: [PATCH] Fix 200% download progress and installedMods backup/restore --- QuestAppVersionSwitcher/ClientModels.cs | 2 ++ QuestAppVersionSwitcher/DownloadManager.cs | 1 + QuestAppVersionSwitcher/GameDownloadManager.cs | 2 +- QuestAppVersionSwitcher/WebServer.cs | 9 +++++---- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/QuestAppVersionSwitcher/ClientModels.cs b/QuestAppVersionSwitcher/ClientModels.cs index 662de76..27e7bb6 100644 --- a/QuestAppVersionSwitcher/ClientModels.cs +++ b/QuestAppVersionSwitcher/ClientModels.cs @@ -87,6 +87,8 @@ public class DownloadProgress public string version { get; set; } = ""; public double percentage { get; set; } = 0.0; public string percentageString { get; set; } = ""; + + public bool downloadDone { get; set; } = false; public long done { get; set; } = 0; public long total { get; set; } = 0; public long speed { get; set; } = 0; diff --git a/QuestAppVersionSwitcher/DownloadManager.cs b/QuestAppVersionSwitcher/DownloadManager.cs index 7b99a1e..dc786d7 100644 --- a/QuestAppVersionSwitcher/DownloadManager.cs +++ b/QuestAppVersionSwitcher/DownloadManager.cs @@ -110,6 +110,7 @@ public void StartDownload(string binaryid, string password, string version, stri this.percentage = 1.0; this.percentageString = "100%"; this.textColor = "#30e34b"; + this.downloadDone = true; QAVSWebserver.BroadcastDownloads(true); }; downloader.OnDownloadError = () => diff --git a/QuestAppVersionSwitcher/GameDownloadManager.cs b/QuestAppVersionSwitcher/GameDownloadManager.cs index f34b932..f44151b 100644 --- a/QuestAppVersionSwitcher/GameDownloadManager.cs +++ b/QuestAppVersionSwitcher/GameDownloadManager.cs @@ -255,7 +255,7 @@ public void UpdateManagersAndProgress() { UpdateMaxConnections(); totalBytes = apkDownloadManager.total + allObbs.Select(x => x.sizeNumerical).Sum(); - downloadedBytes = downloadedFilesTotalBytes + apkDownloadManager.done + downloadManagers.Where(x => x.isObb).Select(x => x.done).Sum(); + downloadedBytes = downloadedFilesTotalBytes + (apkDownloadManager.downloadDone ? 0 : apkDownloadManager.done) + downloadManagers.Where(x => x.isObb).Select(x => x.done).Sum(); // Speed double secondsPassed = (DateTime.Now - lastUpdate).TotalSeconds; diff --git a/QuestAppVersionSwitcher/WebServer.cs b/QuestAppVersionSwitcher/WebServer.cs index 62b4cf9..cf9a67c 100644 --- a/QuestAppVersionSwitcher/WebServer.cs +++ b/QuestAppVersionSwitcher/WebServer.cs @@ -863,8 +863,8 @@ public void Start() { Logger.Log("Copying AppData"); if(Directory.Exists(gameDataDir)) FolderPermission.DirectoryCopy(gameDataDir, backupDir + package); - Logger.Log("Copying mods"); - if(Directory.Exists(QAVSModManager.modManager.GetModExtractPath(package))) FolderPermission.DirectoryCopy(QAVSModManager.modManager.GetModExtractPath(package), backupDir + "installedMods"); + Logger.Log("Copying mods from " + QAVSModManager.modManager.GetModExtractPath(package)); + if(Directory.Exists(QAVSModManager.modManager.GetModsExtractPath(package))) FolderPermission.DirectoryCopy(QAVSModManager.modManager.GetModsExtractPath(package), backupDir + "installedMods"); } catch (Exception e) { @@ -1181,8 +1181,9 @@ public void Start() if (Directory.Exists(backupDir + "installedMods")) { Logger.Log("Restoring installed mods of backup " + backupname + " of " + package); - Directory.Delete(QAVSModManager.modManager.GetModExtractPath(package), true); - FolderPermission.DirectoryCopy(backupDir + "installedMods", QAVSModManager.modManager.GetModExtractPath(package)); + Directory.Delete(QAVSModManager.modManager.GetModsExtractPath(package), true); + FolderPermission.DirectoryCopy(backupDir + "installedMods", QAVSModManager.modManager.GetModsExtractPath(package)); + QAVSModManager.Update(); } serverRequest.SendString(GenericResponse.GetResponse("Game data restored", true), "application/json");