Added download queue space checks with new error messages

Implemented disk and device space validation for the download/install queue with per-game and total queue size checks. The UI displays total queue size and updates available device space after each install. Improved error handling and user prompts for insufficient space.

When adding an entry to the queue, we check:
- Free disk space in the current download directory
- Device free space (if sideloading is enabled)
- Whether the download is already queued
- Total queue size against download directory and device free space to prevent over-queuing

When a download starts (e.g., when resuming downloads after a restart), we recheck disk and device space for that download and allow the user to skip it or clear the queue if not.

Space checks are intentionally lenient. We only block downloads when we're confident the download won't fit. If space is close, users will proceed since they'll receive an error during the actual installation when it fails anyway.
This commit is contained in:
jp64k
2026-01-03 05:05:43 +01:00
parent debb204719
commit de6b0e4c70
2 changed files with 987 additions and 536 deletions

39
ADB.cs
View File

@@ -287,18 +287,38 @@ namespace AndroidSideloader
{
Logger.Log($"SideloadWithProgressAsync error: {ex.Message}", LogLevel.ERROR);
if (ex.Message.Contains("INSTALL_FAILED") ||
ex.Message.Contains("signatures do not match"))
// Signature mismatches and version downgrades can be fixed by reinstalling
bool isReinstallEligible = ex.Message.Contains("signatures do not match") ||
ex.Message.Contains("INSTALL_FAILED_VERSION_DOWNGRADE") ||
ex.Message.Contains("failed to install");
// For insufficient storage, offer reinstall if it's an upgrade
// As uninstalling old version frees space for the new one
bool isStorageIssue = ex.Message.Contains("INSUFFICIENT_STORAGE");
bool isUpgrade = !string.IsNullOrEmpty(packagename) &&
settings.InstalledApps.Contains(packagename);
if (isStorageIssue && isUpgrade)
{
isReinstallEligible = true;
}
if (isReinstallEligible)
{
bool cancelClicked = false;
if (!settings.AutoReinstall)
{
string message = isStorageIssue
? "Installation failed due to insufficient storage. Since this is an upgrade, Rookie can uninstall the old version first to free up space, then install the new version.\n\nRookie will also attempt to backup your save data and reinstall the game automatically, however some games do not store their saves in an accessible location (less than 5%). Continue with reinstall?"
: "In place upgrade has failed. Rookie will attempt to backup your save data and reinstall the game automatically, however some games do not store their saves in an accessible location (less than 5%). Continue with reinstall?";
string title = isStorageIssue ? "Insufficient Storage" : "In place upgrade failed";
Program.form.Invoke(() =>
{
DialogResult dialogResult1 = FlexibleMessageBox.Show(Program.form,
"In place upgrade has failed. Rookie can attempt to backup your save data and reinstall the game automatically, however some games do not store their saves in an accessible location (less than 5%). Continue with reinstall?",
"In place upgrade failed.", MessageBoxButtons.OKCancel);
message, title, MessageBoxButtons.OKCancel);
if (dialogResult1 == DialogResult.Cancel)
cancelClicked = true;
});
@@ -316,7 +336,7 @@ namespace AndroidSideloader
var packageManager = new PackageManager(client, device);
statusCallback?.Invoke("Backing up save data...");
_ = RunAdbCommandToString($"pull \"/sdcard/Android/data/{MainForm.CurrPCKG}\" \"{Environment.CurrentDirectory}\"");
_ = RunAdbCommandToString($"pull \"/sdcard/Android/data/{packagename}\" \"{Environment.CurrentDirectory}\"");
statusCallback?.Invoke("Uninstalling old version...");
packageManager.UninstallPackage(packagename);
@@ -332,9 +352,9 @@ namespace AndroidSideloader
packageManager.InstallPackage(path, reinstallProgress);
statusCallback?.Invoke("Restoring save data...");
_ = RunAdbCommandToString($"push \"{Environment.CurrentDirectory}\\{MainForm.CurrPCKG}\" /sdcard/Android/data/");
_ = RunAdbCommandToString($"push \"{Environment.CurrentDirectory}\\{packagename}\" /sdcard/Android/data/");
string directoryToDelete = Path.Combine(Environment.CurrentDirectory, MainForm.CurrPCKG);
string directoryToDelete = Path.Combine(Environment.CurrentDirectory, packagename);
if (Directory.Exists(directoryToDelete) && directoryToDelete != Environment.CurrentDirectory)
{
Directory.Delete(directoryToDelete, true);
@@ -345,11 +365,12 @@ namespace AndroidSideloader
}
catch (Exception reinstallEx)
{
return new ProcessOutput($"{gameName}: Reinstall: Failed: {reinstallEx.Message}\n");
return new ProcessOutput("", $"{gameName}: Reinstall Failed: {reinstallEx.Message}\n");
}
}
return new ProcessOutput("", ex.Message);
// Return the error message so it's displayed to the user
return new ProcessOutput("", $"\n{gameName}: {ex.Message}");
}
}

File diff suppressed because it is too large Load Diff