mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-30 07:31:36 +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
|
@ -61,9 +61,11 @@ namespace CodeImp.DoomBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DoWork(object sender, DoWorkEventArgs e)
|
private static void DoWork(object sender, DoWorkEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
string updaterpath = Path.Combine(General.AppPath, "Updater.exe");
|
string updaterpath = Path.Combine(General.AppPath, "Updater.exe");
|
||||||
if(!File.Exists(updaterpath))
|
if (!File.Exists(updaterpath))
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: \"" + updaterpath + "\" does not exist!");
|
ShowResult("Update check failed: \"" + updaterpath + "\" does not exist!");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
|
@ -71,7 +73,7 @@ namespace CodeImp.DoomBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
string inipath = Path.Combine(General.AppPath, "Updater.ini");
|
string inipath = Path.Combine(General.AppPath, "Updater.ini");
|
||||||
if(!File.Exists(inipath))
|
if (!File.Exists(inipath))
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: \"" + inipath + "\" does not exist!");
|
ShowResult("Update check failed: \"" + inipath + "\" does not exist!");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
|
@ -82,21 +84,21 @@ namespace CodeImp.DoomBuilder
|
||||||
string url = string.Empty;
|
string url = string.Empty;
|
||||||
string updaterpackname = string.Empty;
|
string updaterpackname = string.Empty;
|
||||||
string[] inilines = File.ReadAllLines(inipath);
|
string[] inilines = File.ReadAllLines(inipath);
|
||||||
foreach(string line in inilines)
|
foreach (string line in inilines)
|
||||||
{
|
{
|
||||||
string cplatform = (Environment.Is64BitProcess ? "x64" : "x86");
|
string cplatform = (Environment.Is64BitProcess ? "x64" : "x86");
|
||||||
if(line.StartsWith("URL")) url = line.Substring(3).Trim();
|
if (line.StartsWith("URL")) url = line.Substring(3).Trim();
|
||||||
else if(line.StartsWith("UpdaterName")) updaterpackname = line.Substring(11).Trim().Replace("[PLATFORM]", cplatform);
|
else if (line.StartsWith("UpdaterName")) updaterpackname = line.Substring(11).Trim().Replace("[PLATFORM]", cplatform);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(url))
|
if (string.IsNullOrEmpty(url))
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: failed to get update url from Updater.ini!");
|
ShowResult("Update check failed: failed to get update url from Updater.ini!");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(updaterpackname))
|
if (string.IsNullOrEmpty(updaterpackname))
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: failed to get updater pack name from Updater.ini!");
|
ShowResult("Update check failed: failed to get updater pack name from Updater.ini!");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
|
@ -106,12 +108,12 @@ namespace CodeImp.DoomBuilder
|
||||||
// Get local revision number
|
// Get local revision number
|
||||||
int localrev = General.ThisAssembly.GetName().Version.Revision;
|
int localrev = General.ThisAssembly.GetName().Version.Revision;
|
||||||
int actuallocalrev = localrev;
|
int actuallocalrev = localrev;
|
||||||
if(!verbose) localrev = Math.Max(localrev, General.Settings.IgnoredRemoteRevision);
|
if (!verbose) localrev = Math.Max(localrev, General.Settings.IgnoredRemoteRevision);
|
||||||
|
|
||||||
// Get remote revision numbers
|
// Get remote revision numbers
|
||||||
int remoterev, remoteupdaterrev;
|
int remoterev, remoteupdaterrev;
|
||||||
MemoryStream stream = DownloadWebFile(Path.Combine(url, "Versions.txt"));
|
MemoryStream stream = DownloadWebFile(Path.Combine(url, "Versions.txt"));
|
||||||
if(stream == null)
|
if (stream == null)
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: failed to retrieve remote revision info.\nCheck your Internet connection and try again.");
|
ShowResult("Update check failed: failed to retrieve remote revision info.\nCheck your Internet connection and try again.");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
|
@ -119,26 +121,26 @@ namespace CodeImp.DoomBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> lines = new List<string>(2);
|
List<string> lines = new List<string>(2);
|
||||||
using(StreamReader reader = new StreamReader(stream))
|
using (StreamReader reader = new StreamReader(stream))
|
||||||
{
|
{
|
||||||
while(!reader.EndOfStream) lines.Add(reader.ReadLine());
|
while (!reader.EndOfStream) lines.Add(reader.ReadLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lines.Count != 2)
|
if (lines.Count != 2)
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: invalid remote revision number.");
|
ShowResult("Update check failed: invalid remote revision number.");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!int.TryParse(lines[0], out remoterev))
|
if (!int.TryParse(lines[0], out remoterev))
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: failed to retrieve remote revision number.");
|
ShowResult("Update check failed: failed to retrieve remote revision number.");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!int.TryParse(lines[1], out remoteupdaterrev))
|
if (!int.TryParse(lines[1], out remoteupdaterrev))
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: failed to retrieve remote updater revision number.");
|
ShowResult("Update check failed: failed to retrieve remote updater revision number.");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
|
@ -147,19 +149,19 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Update the updater!
|
// Update the updater!
|
||||||
string result = UpdateUpdater(url, updaterpackname, remoteupdaterrev);
|
string result = UpdateUpdater(url, updaterpackname, remoteupdaterrev);
|
||||||
if(!string.IsNullOrEmpty(result))
|
if (!string.IsNullOrEmpty(result))
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: " + result);
|
ShowResult("Update check failed: " + result);
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(remoterev > localrev)
|
if (remoterev > localrev)
|
||||||
{
|
{
|
||||||
// Get changelog info
|
// Get changelog info
|
||||||
string changelog = GetChangelog(url, actuallocalrev);
|
string changelog = GetChangelog(url, actuallocalrev);
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(changelog))
|
if (string.IsNullOrEmpty(changelog))
|
||||||
{
|
{
|
||||||
ShowResult("Update check failed: failed to retrieve changelog.\nCheck your Internet connection and try again.");
|
ShowResult("Update check failed: failed to retrieve changelog.\nCheck your Internet connection and try again.");
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
|
@ -169,11 +171,16 @@ namespace CodeImp.DoomBuilder
|
||||||
// Pass data to MainForm
|
// Pass data to MainForm
|
||||||
General.MainWindow.UpdateAvailable(remoterev, changelog);
|
General.MainWindow.UpdateAvailable(remoterev, changelog);
|
||||||
}
|
}
|
||||||
else if(verbose)
|
else if (verbose)
|
||||||
{
|
{
|
||||||
ShowResult(NO_UPDATE_REQUIRED);
|
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)
|
private static string UpdateUpdater(string url, string updaterpackname, int remoterev)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,5 +6,4 @@
|
||||||
<runtime>
|
<runtime>
|
||||||
<loadFromRemoteSources enabled="true"/>
|
<loadFromRemoteSources enabled="true"/>
|
||||||
</runtime>
|
</runtime>
|
||||||
<dllmap dll="devil.dll" target="libIL.so.1" os="linux" />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Loading…
Reference in a new issue