Author: jflesch
Date: 2007-08-15 17:33:49 +0000 (Wed, 15 Aug 2007)
New Revision: 14709
Modified:
trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
Log:
Fix the index comment fetching : Don't purge the comments of an index before
fetching them else you can't know if a comment is new or not ...
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-08-15 17:25:52 UTC
(rev 14708)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-08-15 17:33:49 UTC
(rev 14709)
@@ -111,7 +111,7 @@
private Comment() {
-
+ newComment = false;
}
@@ -126,6 +126,7 @@
this.comment = comment;
this.index = index;
this.rev = rev;
+ newComment = false;
}
@@ -622,11 +623,21 @@
* @see org.xml.sax.ContentHandler#endDocument()
*/
public void endDocument() throws SAXException {
+ valid = false;
+
try {
if (comment != null && authorTxt != null
- && publicKey != null && sig != null) {
+ && publicKey != null && sig != null
+ && index != null) {
author = Identity.getIdentity(db,
authorTxt, publicKey);
+
+ if (author == null) {
+ Logger.warning(this, "Can't
find the identity in the DB ?! WTF ?!");
+ valid = false;
+ return;
+ }
+
valid =
author.check(index.getCommentPublicKey()+"-"+
author.getNick()+"-"+
comment,
@@ -654,7 +665,7 @@
public boolean parseComment(java.io.File xmlFile) {
newComment = false;
- Logger.info(this, "Parsing comment ...");
+ Logger.info(this, "Parsing comment :
"+index.getCommentPublicKey() + " : "+Integer.toString(rev));
FileInputStream in;
@@ -668,7 +679,6 @@
CommentHandler handler = new CommentHandler();
try {
- // Use the default (non-validating) parser
SAXParserFactory factory =
SAXParserFactory.newInstance();
// Parse the input
@@ -690,6 +700,8 @@
if (existsInTheBdd()) {
Logger.debug(this, "Comment
already in db");
+ newComment = false;
+ valid = false;
return false;
}
@@ -731,12 +743,21 @@
return (comment != null && author != null);
}
+ public boolean isValid() {
+ return valid;
+ }
+
/**
* r and s must be set
* You have to do the synchronized(db.dbLock) !
*/
private boolean existsInTheBdd() {
+ if (sig == null) {
+ Logger.notice(this, "No sig, can't say if it's already
in the bdd");
+ return true;
+ }
+
try {
PreparedStatement st;
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-08-15 17:25:52 UTC
(rev 14708)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-08-15 17:33:49 UTC
(rev 14709)
@@ -1027,7 +1027,7 @@
if (c.exists()) {
nmbFailedCommentFetching = 0;
- if (c.isNew()) {
+ if (c.isNew() && c.isValid()) {
Logger.info(this, "New comment !");
setNewCommentFlag(true);
@@ -1081,7 +1081,8 @@
public void purgeIndex(boolean useDontDelete) {
purgeFileList(useDontDelete);
purgeLinkList(useDontDelete);
- purgeCommentKeys();
+ if (!useDontDelete)
+ purgeCommentKeys();
}
@@ -1447,6 +1448,12 @@
}
public boolean setNewCommentFlagInMem(boolean flag) {
+ try {
+ throw new Exception("bleh");
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
newComment = flag;
return true;
}