mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Added error reporting to Update Checker; Fixed update checking failure in certain setups
This commit is contained in:
parent
fb925016ae
commit
d559ba30d7
3 changed files with 107 additions and 101 deletions
|
@ -58,121 +58,128 @@ namespace CodeImp.DoomBuilder
|
|||
worker.RunWorkerCompleted += RunWorkerCompleted;
|
||||
worker.WorkerSupportsCancellation = true;
|
||||
worker.RunWorkerAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private static void DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
string updaterpath = Path.Combine(General.AppPath, "Updater.exe");
|
||||
if(!File.Exists(updaterpath))
|
||||
{
|
||||
ShowResult("Update check failed: \"" + updaterpath + "\" does not exist!");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
string inipath = Path.Combine(General.AppPath, "Updater.ini");
|
||||
if(!File.Exists(inipath))
|
||||
{
|
||||
ShowResult("Update check failed: \"" + inipath + "\" does not exist!");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
string updaterpath = Path.Combine(General.AppPath, "Updater.exe");
|
||||
if (!File.Exists(updaterpath))
|
||||
{
|
||||
ShowResult("Update check failed: \"" + updaterpath + "\" does not exist!");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get some ini values...
|
||||
string url = string.Empty;
|
||||
string updaterpackname = string.Empty;
|
||||
string[] inilines = File.ReadAllLines(inipath);
|
||||
foreach(string line in inilines)
|
||||
{
|
||||
string cplatform = (Environment.Is64BitProcess ? "x64" : "x86");
|
||||
if(line.StartsWith("URL")) url = line.Substring(3).Trim();
|
||||
else if(line.StartsWith("UpdaterName")) updaterpackname = line.Substring(11).Trim().Replace("[PLATFORM]", cplatform);
|
||||
}
|
||||
string inipath = Path.Combine(General.AppPath, "Updater.ini");
|
||||
if (!File.Exists(inipath))
|
||||
{
|
||||
ShowResult("Update check failed: \"" + inipath + "\" does not exist!");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(url))
|
||||
{
|
||||
ShowResult("Update check failed: failed to get update url from Updater.ini!");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
// Get some ini values...
|
||||
string url = string.Empty;
|
||||
string updaterpackname = string.Empty;
|
||||
string[] inilines = File.ReadAllLines(inipath);
|
||||
foreach (string line in inilines)
|
||||
{
|
||||
string cplatform = (Environment.Is64BitProcess ? "x64" : "x86");
|
||||
if (line.StartsWith("URL")) url = line.Substring(3).Trim();
|
||||
else if (line.StartsWith("UpdaterName")) updaterpackname = line.Substring(11).Trim().Replace("[PLATFORM]", cplatform);
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(updaterpackname))
|
||||
{
|
||||
ShowResult("Update check failed: failed to get updater pack name from Updater.ini!");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
ShowResult("Update check failed: failed to get update url from Updater.ini!");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get local revision number
|
||||
int localrev = General.ThisAssembly.GetName().Version.Revision;
|
||||
int actuallocalrev = localrev;
|
||||
if(!verbose) localrev = Math.Max(localrev, General.Settings.IgnoredRemoteRevision);
|
||||
if (string.IsNullOrEmpty(updaterpackname))
|
||||
{
|
||||
ShowResult("Update check failed: failed to get updater pack name from Updater.ini!");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get remote revision numbers
|
||||
int remoterev, remoteupdaterrev;
|
||||
MemoryStream stream = DownloadWebFile(Path.Combine(url, "Versions.txt"));
|
||||
if(stream == null)
|
||||
{
|
||||
ShowResult("Update check failed: failed to retrieve remote revision info.\nCheck your Internet connection and try again.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
// Get local revision number
|
||||
int localrev = General.ThisAssembly.GetName().Version.Revision;
|
||||
int actuallocalrev = localrev;
|
||||
if (!verbose) localrev = Math.Max(localrev, General.Settings.IgnoredRemoteRevision);
|
||||
|
||||
List<string> lines = new List<string>(2);
|
||||
using(StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
while(!reader.EndOfStream) lines.Add(reader.ReadLine());
|
||||
}
|
||||
// Get remote revision numbers
|
||||
int remoterev, remoteupdaterrev;
|
||||
MemoryStream stream = DownloadWebFile(Path.Combine(url, "Versions.txt"));
|
||||
if (stream == null)
|
||||
{
|
||||
ShowResult("Update check failed: failed to retrieve remote revision info.\nCheck your Internet connection and try again.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(lines.Count != 2)
|
||||
{
|
||||
ShowResult("Update check failed: invalid remote revision number.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
List<string> lines = new List<string>(2);
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
while (!reader.EndOfStream) lines.Add(reader.ReadLine());
|
||||
}
|
||||
|
||||
if(!int.TryParse(lines[0], out remoterev))
|
||||
{
|
||||
ShowResult("Update check failed: failed to retrieve remote revision number.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
if (lines.Count != 2)
|
||||
{
|
||||
ShowResult("Update check failed: invalid remote revision number.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!int.TryParse(lines[1], out remoteupdaterrev))
|
||||
{
|
||||
ShowResult("Update check failed: failed to retrieve remote updater revision number.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
if (!int.TryParse(lines[0], out remoterev))
|
||||
{
|
||||
ShowResult("Update check failed: failed to retrieve remote revision number.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the updater!
|
||||
string result = UpdateUpdater(url, updaterpackname, remoteupdaterrev);
|
||||
if(!string.IsNullOrEmpty(result))
|
||||
{
|
||||
ShowResult("Update check failed: " + result);
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
if (!int.TryParse(lines[1], out remoteupdaterrev))
|
||||
{
|
||||
ShowResult("Update check failed: failed to retrieve remote updater revision number.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(remoterev > localrev)
|
||||
{
|
||||
// Get changelog info
|
||||
string changelog = GetChangelog(url, actuallocalrev);
|
||||
// Update the updater!
|
||||
string result = UpdateUpdater(url, updaterpackname, remoteupdaterrev);
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
ShowResult("Update check failed: " + result);
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(changelog))
|
||||
{
|
||||
ShowResult("Update check failed: failed to retrieve changelog.\nCheck your Internet connection and try again.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
if (remoterev > localrev)
|
||||
{
|
||||
// Get changelog info
|
||||
string changelog = GetChangelog(url, actuallocalrev);
|
||||
|
||||
// Pass data to MainForm
|
||||
General.MainWindow.UpdateAvailable(remoterev, changelog);
|
||||
}
|
||||
else if(verbose)
|
||||
{
|
||||
ShowResult(NO_UPDATE_REQUIRED);
|
||||
}
|
||||
if (string.IsNullOrEmpty(changelog))
|
||||
{
|
||||
ShowResult("Update check failed: failed to retrieve changelog.\nCheck your Internet connection and try again.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Pass data to MainForm
|
||||
General.MainWindow.UpdateAvailable(remoterev, changelog);
|
||||
}
|
||||
else if (verbose)
|
||||
{
|
||||
ShowResult(NO_UPDATE_REQUIRED);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, string.Format("Update check failed:\n\n{0}", ex.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static string UpdateUpdater(string url, string updaterpackname, int remoterev)
|
||||
|
|
|
@ -3164,7 +3164,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//mxd. Check updates clicked
|
||||
private void itemhelpcheckupdates_Click(object sender, EventArgs e)
|
||||
{
|
||||
UpdateChecker.PerformCheck(true);
|
||||
UpdateChecker.PerformCheck(true);
|
||||
}
|
||||
|
||||
//mxd. Github issues clicked
|
||||
|
|
|
@ -6,5 +6,4 @@
|
|||
<runtime>
|
||||
<loadFromRemoteSources enabled="true"/>
|
||||
</runtime>
|
||||
<dllmap dll="devil.dll" target="libIL.so.1" os="linux" />
|
||||
</configuration>
|
||||
|
|
Loading…
Reference in a new issue