/* don’t insert locked Sones. */
if (core.isLocked(sone)) {
/* trigger redetection when the Sone is unlocked. */
+ synchronized (sone) {
+ modified = !sone.getFingerprint().equals(lastInsertFingerprint);
+ }
lastFingerprint = "";
lastModificationTime = 0;
continue;
} 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;
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 });
soneProperties.put("posts", new ArrayList<Post>(sone.getPosts()));
soneProperties.put("replies", new HashSet<Reply>(sone.getReplies()));
soneProperties.put("likedPostIds", new HashSet<String>(sone.getLikedPostIds()));
- soneProperties.put("likeReplyIds", new HashSet<String>(sone.getLikedReplyIds()));
+ soneProperties.put("likedReplyIds", new HashSet<String>(sone.getLikedReplyIds()));
}
//
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
//