From 515b4791dd243cfc3c29e4be855cef6e68352104 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 24 Dec 2008 11:45:53 +0100 Subject: [PATCH] Report every found version. Check for next edition after having found one. --- src/de/todesbaum/jsite/gui/UpdateChecker.java | 40 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/de/todesbaum/jsite/gui/UpdateChecker.java b/src/de/todesbaum/jsite/gui/UpdateChecker.java index d151ed0..aa0b9ab 100644 --- a/src/de/todesbaum/jsite/gui/UpdateChecker.java +++ b/src/de/todesbaum/jsite/gui/UpdateChecker.java @@ -149,10 +149,13 @@ public class UpdateChecker implements Runnable { e1.printStackTrace(); } Client client = new Client(connection); + boolean checkNow = false; + int currentEdition = lastUpdateEdition; while (!shouldStop()) { - System.out.println("Trying " + constructUpdateKey(lastUpdateEdition)); + checkNow = false; + System.out.println("Trying " + constructUpdateKey(currentEdition)); ClientGet clientGet = new ClientGet("get-update-key"); - clientGet.setUri(constructUpdateKey(lastUpdateEdition)); + clientGet.setUri(constructUpdateKey(currentEdition)); clientGet.setPersistence(Persistence.CONNECTION); clientGet.setReturnType(ReturnType.direct); clientGet.setVerbosity(Verbosity.ALL); @@ -173,7 +176,9 @@ public class UpdateChecker implements Runnable { } if (editionNumber != -1) { System.out.println("Found new edition " + editionNumber); + currentEdition = editionNumber; lastUpdateEdition = editionNumber; + checkNow = true; break; } } @@ -193,17 +198,19 @@ public class UpdateChecker implements Runnable { if (foundVersionString != null) { Version foundVersion = Version.parse(foundVersionString); if (foundVersion != null) { - if (foundVersion.compareTo(Main.getVersion()) > 0) { - lastVersion = foundVersion; - String versionTimestampString = properties.getProperty("jSite.Date"); - long versionTimestamp = -1; - try { - versionTimestamp = Long.parseLong(versionTimestampString); - } catch (NumberFormatException nfe1) { - /* ignore. */ - } - fireUpdateFound(foundVersion, versionTimestamp); + lastVersion = foundVersion; + String versionTimestampString = properties.getProperty("jSite.Date"); + System.out.println(versionTimestampString); + long versionTimestamp = -1; + try { + versionTimestamp = Long.parseLong(versionTimestampString); + } catch (NumberFormatException nfe1) { + /* ignore. */ } + fireUpdateFound(foundVersion, versionTimestamp); + stop = true; + checkNow = true; + ++currentEdition; } } } @@ -212,6 +219,15 @@ public class UpdateChecker implements Runnable { System.out.println("Got IOException: " + e.getMessage()); e.printStackTrace(); } + if (!checkNow && !shouldStop()) { + synchronized (syncObject) { + try { + syncObject.wait(15 * 60 * 1000); + } catch (InterruptedException ie1) { + /* ignore. */ + } + } + } } } } -- 2.7.4