From 0001614e7188967fabe8597d4c5663952ab19197 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 16 Jan 2011 20:13:58 +0100 Subject: [PATCH] Only set the insert time after the insert has finished. Fixes #30. --- .../java/net/pterodactylus/sone/core/SoneInserter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index fec4e8f..c15b1d0 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -182,7 +182,6 @@ public class SoneInserter extends AbstractService { } else { lastModificationTime = System.currentTimeMillis(); modified = true; - sone.setTime(lastModificationTime); logger.log(Level.FINE, "Sone %s has been modified, waiting %d seconds before inserting.", new Object[] { sone.getName(), insertionDelay }); } lastFingerprint = fingerprint; @@ -199,12 +198,15 @@ public class SoneInserter extends AbstractService { boolean success = false; try { core.setSoneStatus(sone, SoneStatus.inserting); + long insertTime = System.currentTimeMillis(); + insertInformation.setTime(insertTime); FreenetURI finalUri = freenetInterface.insertDirectory(insertInformation.getInsertUri().setKeyType("USK").setSuggestedEdition(0), insertInformation.generateManifestEntries(), "index.html"); /* at this point we might already be stopped. */ if (shouldStop()) { /* if so, bail out, don’t change anything. */ break; } + sone.setTime(insertTime); sone.setLatestEdition(finalUri.getEdition()); success = true; logger.log(Level.INFO, "Inserted Sone “%s” at %s.", new Object[] { sone.getName(), finalUri }); @@ -276,6 +278,16 @@ public class SoneInserter extends AbstractService { return (FreenetURI) soneProperties.get("insertUri"); } + /** + * Sets the time of the Sone at the time of the insert. + * + * @param time + * The time of the Sone + */ + public void setTime(long time) { + soneProperties.put("time", time); + } + // // ACTIONS // -- 2.7.4