Author: jflesch
Date: 2007-08-15 13:12:20 +0000 (Wed, 15 Aug 2007)
New Revision: 14694

Modified:
   trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
Log:
When using 'add specific keys' on an index, the check to be sure that the key 
is not already in the index should compare precisly the keys (not only the 40 
first car.)

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2007-08-15 13:07:53 UTC (rev 14693)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2007-08-15 13:12:20 UTC (rev 14694)
@@ -1400,7 +1400,7 @@

                synchronized(db.dbLock) {
                        try {
-                               preSt = 
db.getConnection().prepareStatement("SELECT id FROM files "+
+                               preSt = 
db.getConnection().prepareStatement("SELECT id, publicKey FROM files "+
                                                                            
"WHERE indexParent = ? AND "+
                                                                            
"LOWER(publicKey) LIKE ? LIMIT 1");

@@ -1428,8 +1428,17 @@

                                        ResultSet res = preSt.executeQuery();

-                                       if (!res.next()) {
+                                       boolean alreadyThere = false;

+                                       if (res.next()) {
+                                               String pubKey = 
res.getString("publicKey");
+
+                                               if 
(FreenetURIHelper.compareKeys(key, pubKey))
+                                                       alreadyThere = true;
+                                       }
+
+                                       if (alreadyThere) {
+
                                                st.setInt(1, nextId);
                                                st.setString(2, 
FreenetURIHelper.getFilenameFromKey(key));
                                                st.setString(3, key);


Reply via email to