Update comments & add comments
This commit is contained in:
57
MainForm.cs
57
MainForm.cs
@@ -63,7 +63,7 @@ namespace AndroidSideloader
|
||||
private bool manualIP;
|
||||
public MainForm()
|
||||
{
|
||||
// check for offline mode
|
||||
// Check for Offline Mode or No RCLONE Updating
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
foreach (string arg in args)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ namespace AndroidSideloader
|
||||
Properties.Settings.Default.SubmittedUpdates = String.Empty;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
//Time for debuglog
|
||||
// Launch time used within debuglog.
|
||||
string launchtime = DateTime.Now.ToString("hh:mmtt(UTC)");
|
||||
_ = Logger.Log($"\n------\n------\nProgram Launched at: {launchtime}\n------\n------");
|
||||
if (string.IsNullOrEmpty(Properties.Settings.Default.CurrentLogPath))
|
||||
@@ -1003,7 +1003,7 @@ namespace AndroidSideloader
|
||||
string gameName = $"{GameName} v{VersionInt} {packageName} {HWID.Substring(0, 1)}";
|
||||
string gameZipName = $"{gameName}.zip";
|
||||
|
||||
// delete the zip and txt if they exist from a previously failed upload
|
||||
// Delete both zip & txt if the files exist, most likely due to a failed upload.
|
||||
if (File.Exists($"{Properties.Settings.Default.MainDir}\\{gameZipName}"))
|
||||
{
|
||||
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameZipName}");
|
||||
@@ -1078,15 +1078,15 @@ namespace AndroidSideloader
|
||||
string currentlyUploading = GameName;
|
||||
changeTitle("Uploading to server, you can continue to use Rookie while it uploads in the background.");
|
||||
|
||||
// get size of pending zip upload and write to text file
|
||||
// Get size of pending zip upload and write to text file
|
||||
long zipSize = new FileInfo($"{Properties.Settings.Default.MainDir}\\{gameZipName}").Length;
|
||||
File.WriteAllText($"{Properties.Settings.Default.MainDir}\\{gameName}.txt", zipSize.ToString());
|
||||
// upload size file
|
||||
// Upload size file.
|
||||
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{Properties.Settings.Default.MainDir}\\{gameName}.txt\" RSL-gameuploads:");
|
||||
// upload zip
|
||||
// Upload zip.
|
||||
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{Properties.Settings.Default.MainDir}\\{gameZipName}\" RSL-gameuploads:");
|
||||
|
||||
// deleting uploaded files
|
||||
// Delete files once uploaded.
|
||||
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameName}.txt");
|
||||
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameZipName}");
|
||||
|
||||
@@ -1272,7 +1272,7 @@ namespace AndroidSideloader
|
||||
CurrAPK = file2;
|
||||
System.Windows.Forms.Timer t3 = new System.Windows.Forms.Timer
|
||||
{
|
||||
Interval = 150000 // 180 seconds to fail
|
||||
Interval = 150000 // 150 seconds to fail
|
||||
};
|
||||
t3.Tick += timer_Tick4;
|
||||
t3.Start();
|
||||
@@ -1621,8 +1621,8 @@ namespace AndroidSideloader
|
||||
List<string> blacklistItems = blacklist.ToList();
|
||||
List<string> whitelistItems = whitelist.ToList();
|
||||
errorOnList = false;
|
||||
//This is for black list, but temporarly will be whitelist
|
||||
//this list has games that we are actually going to upload
|
||||
//This is for the black list, but temporarily will be the whitelist
|
||||
//This list contains games that we are actually going to upload
|
||||
newGamesToUploadList = whitelistItems.Intersect(installedGames).ToList();
|
||||
progressBar.Style = ProgressBarStyle.Marquee;
|
||||
if (SideloaderRCLONE.games.Count > 5)
|
||||
@@ -1915,7 +1915,7 @@ namespace AndroidSideloader
|
||||
string gameName = $"{game.Uploadgamename} v{game.Uploadversion} {game.Pckgcommand} {SideloaderUtilities.UUID().Substring(0, 1)}";
|
||||
string gameZipName = $"{gameName}.zip";
|
||||
|
||||
// delete the zip and txt if they exist from a previously failed upload
|
||||
// Delete both zip & txt if the files exist, most likely due to a failed upload.
|
||||
if (File.Exists($"{Properties.Settings.Default.MainDir}\\{gameZipName}"))
|
||||
{
|
||||
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameZipName}");
|
||||
@@ -1933,12 +1933,12 @@ namespace AndroidSideloader
|
||||
Directory.Delete($"{Properties.Settings.Default.MainDir}\\{game.Pckgcommand}", true);
|
||||
Program.form.changeTitle("Uploading to server, you may continue to use Rookie while it uploads.");
|
||||
|
||||
// get size of pending zip upload and write to text file
|
||||
// Get size of pending zip upload and write to text file
|
||||
long zipSize = new FileInfo($"{Properties.Settings.Default.MainDir}\\{gameZipName}").Length;
|
||||
File.WriteAllText($"{Properties.Settings.Default.MainDir}\\{gameName}.txt", zipSize.ToString());
|
||||
// upload size file
|
||||
// Upload size file.
|
||||
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{Properties.Settings.Default.MainDir}\\{gameName}.txt\" RSL-gameuploads:");
|
||||
// upload zip
|
||||
// Upload zip.
|
||||
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{Properties.Settings.Default.MainDir}\\{gameZipName}\" RSL-gameuploads:");
|
||||
|
||||
if (game.isUpdate)
|
||||
@@ -1947,7 +1947,7 @@ namespace AndroidSideloader
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
// deleting uploaded files
|
||||
// Delete files once uploaded.
|
||||
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameName}.txt");
|
||||
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameZipName}");
|
||||
|
||||
@@ -2085,7 +2085,7 @@ namespace AndroidSideloader
|
||||
|
||||
remotesList.Invoke(() =>
|
||||
{
|
||||
remotesList.SelectedIndex = 0; //set mirror to first
|
||||
remotesList.SelectedIndex = 0; // Set mirror to first item in array.
|
||||
currentRemote = "VRP-mirror" + remotesList.SelectedItem.ToString();
|
||||
});
|
||||
|
||||
@@ -2490,7 +2490,7 @@ Things you can try:
|
||||
changeTitle("Downloading game " + gameName, false);
|
||||
|
||||
int i = 0;
|
||||
//Download
|
||||
// Begin download.
|
||||
while (t1.IsAlive)
|
||||
{
|
||||
try
|
||||
@@ -2569,7 +2569,7 @@ Things you can try:
|
||||
break;
|
||||
}
|
||||
{
|
||||
//Quota Errors
|
||||
// Handle quota errors.
|
||||
bool isinstalltxt = false;
|
||||
bool quotaError = false;
|
||||
bool otherError = false;
|
||||
@@ -2589,7 +2589,7 @@ Things you can try:
|
||||
{
|
||||
otherError = true;
|
||||
|
||||
//Remove current game
|
||||
// Remove current game off queue.
|
||||
cleanupActiveDownloadStatus();
|
||||
|
||||
_ = FlexibleMessageBox.Show($"Rclone error: {gameDownloadOutput.Error}");
|
||||
@@ -2720,6 +2720,7 @@ Things you can try:
|
||||
{
|
||||
if (!Properties.Settings.Default.nodevicemode | !nodeviceonstart & DeviceConnected)
|
||||
{
|
||||
// Attempt to delete OBB Folder before pushing.
|
||||
deleteOBB(packagename);
|
||||
Thread obbThread = new Thread(() =>
|
||||
{
|
||||
@@ -2742,6 +2743,7 @@ Things you can try:
|
||||
{
|
||||
try
|
||||
{
|
||||
// Check if OBB was properly pushed with a size comparison.
|
||||
obbsMismatch = await compareOBBSizes(packagename, gameName, output);
|
||||
}
|
||||
catch (Exception ex) { _ = FlexibleMessageBox.Show($"Error comparing OBB sizes: {ex.Message}"); }
|
||||
@@ -2764,7 +2766,7 @@ Things you can try:
|
||||
try { Directory.Delete(Properties.Settings.Default.downloadDir + "\\" + gameName, true); } catch (Exception ex) { _ = FlexibleMessageBox.Show($"Error deleting game files: {ex.Message}"); }
|
||||
}
|
||||
|
||||
//Remove current game
|
||||
// Remove current game off queue.
|
||||
cleanupActiveDownloadStatus();
|
||||
}
|
||||
}
|
||||
@@ -2809,6 +2811,7 @@ Things you can try:
|
||||
|
||||
private const string OBBFolderPath = "/sdcard/Android/obb/";
|
||||
|
||||
// Logic to compare OBB folders.
|
||||
private async Task<bool> compareOBBSizes(string packageName, string gameName, ProcessOutput output)
|
||||
{
|
||||
string localFolderPath = Path.Combine(Properties.Settings.Default.downloadDir, gameName, packageName);
|
||||
@@ -2864,6 +2867,7 @@ Things you can try:
|
||||
return Regex.Replace(replaced, "[^0-9]", "");
|
||||
}
|
||||
|
||||
// Logic to handle mismatches after comparison.
|
||||
private async Task<bool> handleObbSizeMismatchAsync(string packageName, string gameName, ProcessOutput output)
|
||||
{
|
||||
var dialogResult = MessageBox.Show("Warning! It seems like the OBB wasn't pushed correctly, this means that the game may not launch correctly.\n Do you want to retry the push?", "OBB Size Mismatch!", MessageBoxButtons.YesNo);
|
||||
@@ -3181,7 +3185,7 @@ Things you can try:
|
||||
{
|
||||
if (keyData == (Keys.Control | Keys.F))
|
||||
{
|
||||
//show search
|
||||
// Show search box.
|
||||
searchTextBox.Clear();
|
||||
searchTextBox.Visible = true;
|
||||
label2.Visible = true;
|
||||
@@ -3235,11 +3239,8 @@ Things you can try:
|
||||
{
|
||||
try
|
||||
{
|
||||
//run the program again and close this one
|
||||
// Relaunch the program using Sideloader Launcher
|
||||
_ = Process.Start(Application.StartupPath + "\\Sideloader Launcher.exe");
|
||||
//or you can use Application.ExecutablePath
|
||||
|
||||
//close this one
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
catch
|
||||
@@ -3704,8 +3705,6 @@ Things you can try:
|
||||
List<string> blacklistItems = blacklist.ToList();
|
||||
List<string> whitelistItems = whitelist.ToList();
|
||||
errorOnList = false;
|
||||
//This is for black list, but temporarly will be whitelist
|
||||
//this list has games that we are actually going to upload
|
||||
newGamesToUploadList = whitelistItems.Intersect(installedGames).ToList();
|
||||
progressBar.Style = ProgressBarStyle.Marquee;
|
||||
if (SideloaderRCLONE.games.Count > 5)
|
||||
@@ -4041,8 +4040,6 @@ Things you can try:
|
||||
List<string> blacklistItems = blacklist.ToList();
|
||||
List<string> whitelistItems = whitelist.ToList();
|
||||
errorOnList = false;
|
||||
//This is for black list, but temporarly will be whitelist
|
||||
//this list has games that we are actually going to upload
|
||||
newGamesToUploadList = whitelistItems.Intersect(installedGames).ToList();
|
||||
progressBar.Style = ProgressBarStyle.Marquee;
|
||||
if (SideloaderRCLONE.games.Count > 5)
|
||||
@@ -4176,8 +4173,6 @@ Things you can try:
|
||||
List<string> blacklistItems = blacklist.ToList();
|
||||
List<string> whitelistItems = whitelist.ToList();
|
||||
errorOnList = false;
|
||||
//This is for black list, but temporarly will be whitelist
|
||||
//this list has games that we are actually going to upload
|
||||
newGamesToUploadList = whitelistItems.Intersect(installedGames).ToList();
|
||||
progressBar.Style = ProgressBarStyle.Marquee;
|
||||
if (SideloaderRCLONE.games.Count > 5)
|
||||
|
||||
@@ -28,9 +28,11 @@ namespace AndroidSideloader
|
||||
|
||||
private static void CrashHandler(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
// Capture unhandled exceptions and write to file.
|
||||
Exception e = (Exception)args.ExceptionObject;
|
||||
string date_time = DateTime.Now.ToString("dddd, MMMM dd @ hh:mmtt (UTC)");
|
||||
File.WriteAllText(Sideloader.CrashLogPath, $"Date/Time of crash: {date_time}\nMessage: {e.Message}\nData: {e.Data}\nSource: {e.Source}\nTargetSite: {e.TargetSite}\nStack Trace: \n{e.StackTrace}\n\n\nDebuglog: \n\n\n");
|
||||
// If a debuglog exists we append it to the crashlog.
|
||||
if (File.Exists(Properties.Settings.Default.CurrentLogPath))
|
||||
{
|
||||
File.AppendAllText(Sideloader.CrashLogPath, File.ReadAllText($"{Properties.Settings.Default.CurrentLogPath}"));
|
||||
|
||||
32
RCLONE.cs
32
RCLONE.cs
@@ -10,7 +10,7 @@ namespace AndroidSideloader
|
||||
{
|
||||
internal class RCLONE
|
||||
{
|
||||
//Kill all rclone, using a static rclone variable doesn't work for some reason #tofix
|
||||
// Kill RCLONE Processes that were started from Rookie by looking for child processes.
|
||||
public static void killRclone()
|
||||
{
|
||||
var parentProcessId = Process.GetCurrentProcess().Id;
|
||||
@@ -38,7 +38,7 @@ namespace AndroidSideloader
|
||||
}
|
||||
}
|
||||
|
||||
//For custom configs that use a password
|
||||
// For custom configs that use a password
|
||||
public static void Init()
|
||||
{
|
||||
string PwTxtPath = Path.Combine(Environment.CurrentDirectory, "rclone\\pw.txt");
|
||||
@@ -48,7 +48,7 @@ namespace AndroidSideloader
|
||||
}
|
||||
}
|
||||
|
||||
//Change if you want to use a config
|
||||
// Change if you want to use a config
|
||||
public static string downloadConfigPath = "vrp.download.config";
|
||||
public static string uploadConfigPath = "vrp.upload.config";
|
||||
public static string rclonepw = "";
|
||||
@@ -56,7 +56,7 @@ namespace AndroidSideloader
|
||||
|
||||
private static readonly Process rclone = new Process();
|
||||
|
||||
//Run rclone command
|
||||
// Run an RCLONE Command that accesses the Download Config.
|
||||
public static ProcessOutput runRcloneCommand_DownloadConfig(string command)
|
||||
{
|
||||
if (MainForm.isOffline)
|
||||
@@ -65,17 +65,17 @@ namespace AndroidSideloader
|
||||
}
|
||||
|
||||
ProcessOutput prcoutput = new ProcessOutput();
|
||||
//Rclone output is unicode, else it will show garbage instead of unicode characters
|
||||
// Rclone output is unicode, else it will show garbage instead of unicode characters
|
||||
rclone.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
string originalCommand = command;
|
||||
|
||||
//set configpath if there is any
|
||||
// set configpath if there is any
|
||||
if (downloadConfigPath.Length > 0)
|
||||
{
|
||||
command += $" --config {downloadConfigPath}";
|
||||
}
|
||||
|
||||
//set rclonepw
|
||||
// set rclonepw
|
||||
if (rclonepw.Length > 0)
|
||||
{
|
||||
command += " --ask-password=false";
|
||||
@@ -101,7 +101,7 @@ namespace AndroidSideloader
|
||||
rclone.StartInfo.RedirectStandardOutput = true;
|
||||
rclone.StartInfo.WorkingDirectory = Environment.CurrentDirectory + "\\rclone";
|
||||
rclone.StartInfo.CreateNoWindow = true;
|
||||
//On debug we want to see when rclone is open
|
||||
// Display RCLONE Window if the binary is being run in Debug Mode.
|
||||
if (MainForm.debugMode)
|
||||
{
|
||||
rclone.StartInfo.CreateNoWindow = false;
|
||||
@@ -125,7 +125,7 @@ namespace AndroidSideloader
|
||||
return new ProcessOutput("Download failed.", "");
|
||||
}
|
||||
|
||||
//if there is one of these errors, we switch the mirrors
|
||||
// Switch mirror upon matching error output.
|
||||
if (error.Contains("400 Bad Request") || error.Contains("cannot fetch token") || error.Contains("authError") || error.Contains("quota") || error.Contains("exceeded") || error.Contains("directory not found") || error.Contains("Failed to"))
|
||||
{
|
||||
string oldRemote = MainForm.currentRemote;
|
||||
@@ -164,10 +164,10 @@ namespace AndroidSideloader
|
||||
public static ProcessOutput runRcloneCommand_UploadConfig(string command)
|
||||
{
|
||||
ProcessOutput prcoutput = new ProcessOutput();
|
||||
//Rclone output is unicode, else it will show garbage instead of unicode characters
|
||||
// Rclone output is unicode, else it will show garbage instead of unicode characters
|
||||
rclone.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
|
||||
//set configpath if there is any
|
||||
// set configpath if there is any
|
||||
if (uploadConfigPath.Length > 0)
|
||||
{
|
||||
command += $" --config {uploadConfigPath}";
|
||||
@@ -195,7 +195,7 @@ namespace AndroidSideloader
|
||||
rclone.StartInfo.RedirectStandardOutput = true;
|
||||
rclone.StartInfo.WorkingDirectory = Environment.CurrentDirectory + "\\rclone";
|
||||
rclone.StartInfo.CreateNoWindow = true;
|
||||
//On debug we want to see when rclone is open
|
||||
// Display RCLONE Window if the binary is being run in Debug Mode.
|
||||
if (MainForm.debugMode)
|
||||
{
|
||||
rclone.StartInfo.CreateNoWindow = false;
|
||||
@@ -210,7 +210,7 @@ namespace AndroidSideloader
|
||||
string error = rclone.StandardError.ReadToEnd();
|
||||
rclone.WaitForExit();
|
||||
|
||||
//if there is one of these errors, we switch the mirrors
|
||||
// if there is one of these errors, we switch the mirrors
|
||||
if (error.Contains("400 Bad Request") || error.Contains("cannot fetch token") || error.Contains("authError") || error.Contains("quota") || error.Contains("exceeded") || error.Contains("directory not found") || error.Contains("Failed to"))
|
||||
{
|
||||
_ = Logger.Log(error, LogLevel.ERROR);
|
||||
@@ -245,7 +245,7 @@ namespace AndroidSideloader
|
||||
}
|
||||
|
||||
ProcessOutput prcoutput = new ProcessOutput();
|
||||
//Rclone output is unicode, else it will show garbage instead of unicode characters
|
||||
// Rclone output is unicode, else it will show garbage instead of unicode characters
|
||||
rclone.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
|
||||
string logcmd = Utilities.StringUtilities.RemoveEverythingBeforeFirst(command, "rclone.exe");
|
||||
@@ -261,7 +261,7 @@ namespace AndroidSideloader
|
||||
|
||||
_ = Logger.Log($"Running Rclone command: {logcmd}");
|
||||
|
||||
//set http source & args
|
||||
// set http source & args
|
||||
command += $" --http-url {MainForm.PublicConfigFile.BaseUri} {MainForm.PublicMirrorExtraArgs}";
|
||||
|
||||
rclone.StartInfo.FileName = Environment.CurrentDirectory + "\\rclone\\rclone.exe";
|
||||
@@ -271,7 +271,7 @@ namespace AndroidSideloader
|
||||
rclone.StartInfo.RedirectStandardOutput = true;
|
||||
rclone.StartInfo.WorkingDirectory = Environment.CurrentDirectory + "\\rclone";
|
||||
rclone.StartInfo.CreateNoWindow = true;
|
||||
//On debug we want to see when rclone is open
|
||||
// Display RCLONE Window if the binary is being run in Debug Mode.
|
||||
if (MainForm.debugMode)
|
||||
{
|
||||
rclone.StartInfo.CreateNoWindow = false;
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace AndroidSideloader
|
||||
catch (Exception ex) { _ = Logger.Log(ex.Message, LogLevel.ERROR); }
|
||||
}
|
||||
|
||||
//uninstalls an app
|
||||
// Removes the game package and its OBB + Data Folders.
|
||||
public static ProcessOutput UninstallGame(string packagename)
|
||||
{
|
||||
ProcessOutput output = ADB.UninstallPackage(packagename);
|
||||
@@ -260,7 +260,7 @@ namespace AndroidSideloader
|
||||
return packageName;
|
||||
}
|
||||
|
||||
//Downloads the required files
|
||||
// Download required dependencies.
|
||||
public static void downloadFiles()
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
|
||||
Reference in New Issue
Block a user