Skip to content

Commit

Permalink
Detect if jar file is corrupt and force a re-download
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbenson committed Oct 24, 2011
1 parent 77b2289 commit bbe3efb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Source/YAMS-Library/Functions/AutoUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static class AutoUpdate
private static string strTectonicusVer = "1.38";

//Checks for available updates
public static void CheckUpdates()
public static void CheckUpdates(bool bolForce = false)
{
YAMS.Database.AddLog("Running update check", "updater");

Expand All @@ -84,6 +84,15 @@ public static void CheckUpdates()
string json = File.ReadAllText(YAMS.Core.RootFolder + @"\lib\versions.json");
//Dictionary<string, string> dicVers = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
JObject jVers = JObject.Parse(json);

//Reset all the JAR etags so we re-download them
if (bolForce)
{
YAMS.Database.AddLog("Forced re-download of JAR files", "updater", "warn");
YAMS.Database.SaveEtag(strMCServerURL, "");
YAMS.Database.SaveEtag((string)jVers["pre"], "");
YAMS.Database.SaveEtag(strBukkitServerURL, "");
}

//Check Minecraft server first
if (bolUpdateJAR)
Expand Down
8 changes: 8 additions & 0 deletions Source/YAMS-Library/Objects/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,14 @@ private void ServerError(object sender, DataReceivedEventArgs e)
}
else { strLevel = "error"; }

if (strMessage.IndexOf("Invalid or corrupt jarfile ") > -1)
{
//We have downloaded a corrupt jar, clear the download cache and force a re-download now
this.SafeStop = true;
AutoUpdate.CheckUpdates(true);
this.Start();
}

Database.AddLog(datTimeStamp, strMessage, "server", strLevel, false, this.ServerID);
}

Expand Down

0 comments on commit bbe3efb

Please sign in to comment.