From: David ‘Bombe’ Roden Date: Sun, 16 Jan 2011 19:13:58 +0000 (+0100) Subject: Only set the insert time after the insert has finished. Fixes #30. X-Git-Tag: 0.4.2^2~38 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0001614e7188967fabe8597d4c5663952ab19197;p=Sone.git Only set the insert time after the insert has finished. Fixes #30. --- 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 //