Skip to content

Commit

Permalink
Fix 200% download progress and installedMods backup/restore
Browse files Browse the repository at this point in the history
  • Loading branch information
ComputerElite committed Jan 30, 2024
1 parent 9c0d890 commit f721e71
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions QuestAppVersionSwitcher/ClientModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions QuestAppVersionSwitcher/DownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () =>
Expand Down
2 changes: 1 addition & 1 deletion QuestAppVersionSwitcher/GameDownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions QuestAppVersionSwitcher/WebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit f721e71

Please sign in to comment.