Author: jflesch
Date: 2007-08-03 20:14:10 +0000 (Fri, 03 Aug 2007)
New Revision: 14478

Modified:
   trunk/apps/Thaw/src/thaw/i18n/regenerated_translations.sh
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/index/Index.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java
Log:
Change the index refresh process : Now they are first downloaded with an USK 
with a positive revision, and next only with a negative revision (will allow 
inital downloads to be done faster)

Modified: trunk/apps/Thaw/src/thaw/i18n/regenerated_translations.sh
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/regenerated_translations.sh   2007-08-03 
19:35:37 UTC (rev 14477)
+++ trunk/apps/Thaw/src/thaw/i18n/regenerated_translations.sh   2007-08-03 
20:14:10 UTC (rev 14478)
@@ -1,4 +1,8 @@
 #!/bin/sh
+
+# Note : Don't use the jdk 1.6.0_02,
+#        there is a regression in native2ascii
+
 SRC_TRANSLATION_PREFIX=source
 FR_TRANSLATION=thaw_fr.properties


Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-08-03 19:35:37 UTC 
(rev 14477)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-08-03 20:14:10 UTC 
(rev 14478)
@@ -297,6 +297,8 @@

 thaw.plugin.index.addAlreadyExistingIndex=Ajouter un index d\u00e9j\u00e0 
existant

+thaw.plugin.index.indexSettings=R\u00e9glages de l'index
+
 thaw.plugin.index.indexKey=Clef publique de l'index:
 thaw.plugin.index.indexPrivateKey=Clef priv\u00e9e de l'index:

@@ -601,3 +603,8 @@
 thaw.plugin.miniFrost.modifyRegexp=Modifier les r\u00e8gles de filtrage

 thaw.plugin.miniFrost.seeTree=Voir les messages sous forme d'arbre
+thaw.plugin.miniFrost.archiveAfter=Archiver automatiquement les messages 
apr\u00e8s:
+thaw.plugin.miniFrost.deleteAfter=Effacer automatiquement les messages 
apr\u00e8s:
+
+thaw.plugin.miniFrost.days=jours
+

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2007-08-03 19:35:37 UTC 
(rev 14477)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2007-08-03 20:14:10 UTC 
(rev 14478)
@@ -415,20 +415,21 @@
        public boolean publishPrivateKey() {
                try {

-               PreparedStatement st
-                               = db.getConnection().prepareStatement("SELECT 
publishPrivateKey FROM indexes WHERE id = ? LIMIT 1");
+                       synchronized(db.dbLock) {
+                               PreparedStatement st
+                                       = 
db.getConnection().prepareStatement("SELECT publishPrivateKey FROM indexes 
WHERE id = ? LIMIT 1");

-                       st.setInt(1, id);
+                               st.setInt(1, id);

-                       ResultSet set = st.executeQuery();
+                               ResultSet set = st.executeQuery();

-                       if (!set.next()) {
-                               Logger.error(this, "Unable to get 
publishPrivateKey value => not found !");
+                               if (!set.next()) {
+                                       Logger.error(this, "Unable to get 
publishPrivateKey value => not found !");
+                               }
+
+                               return set.getBoolean("publishPrivateKey");
                        }

-                       return set.getBoolean("publishPrivateKey");
-
-
                } catch(SQLException e){
                        Logger.error(this, "Unable to get publishPrivateKey 
value because: "+e.toString());
                }
@@ -438,13 +439,15 @@

        public void setPublishPrivateKey(boolean val) {
                try {
-                       PreparedStatement st =
-                               db.getConnection().prepareStatement("UPDATE 
indexes "+
-                                                                   "SET 
publishPrivateKey = ? "+
-                                                                   "WHERE id = 
?");
-                       st.setBoolean(1, val);
-                       st.setInt(2, id);
-                       st.execute();
+                       synchronized(db.dbLock) {
+                               PreparedStatement st =
+                                       
db.getConnection().prepareStatement("UPDATE indexes "+
+                                                                           
"SET publishPrivateKey = ? "+
+                                                                           
"WHERE id = ?");
+                               st.setBoolean(1, val);
+                               st.setInt(2, id);
+                               st.execute();
+                       }

                } catch(SQLException e){
                        Logger.error(this, "Unable to set publishPrivateKey 
value because: "+e.toString());
@@ -736,36 +739,54 @@
         */
        private boolean rewriteKey = true;
        private FCPQueueManager queueManager;
+       private boolean fetchingNegRev = false;
+       private boolean mustFetchNegRev = true;
+       private int specificRev = 0;

+       public int downloadFromFreenet(Observer o, IndexTree tree, 
FCPQueueManager queueManager, int specificRev) {
+               this.queueManager = queueManager;
+               indexTree = tree;
+               rewriteKey = true;

-       public int downloadFromFreenet(Observer o, IndexTree tree, 
FCPQueueManager queueManager, int specificRev) {
+               fetchingNegRev = false;
+               mustFetchNegRev = true;
+
+               if (config != null && config.getValue("indexFetchNegative") != 
null)
+                       mustFetchNegRev = 
Boolean.valueOf(config.getValue("indexFetchNegative")).booleanValue();
+
+               boolean v = realDownloadFromFreenet(specificRev);
+
+               this.addObserver(o);
+
+               return (v ? 1 : 0);
+       }
+
+
+       protected boolean realDownloadFromFreenet(int specificRev) {
                FCPClientGet clientGet;
                String publicKey;

                this.queueManager = queueManager;
+               this.specificRev = specificRev;

                int rev = getRevision();

-               indexTree = tree;
-
-               rewriteKey = true;
-
                publicKey = getPublicKey();
                String privateKey = getPrivateKey();

                if (rev <= 0 && privateKey != null) {
                        Logger.error(this, "Can't update an non-inserted index 
!");
-                       return 0;
+                       return false;
                }

-               if (tree != null && tree.isIndexUpdating(this)) {
+               if (indexTree != null && indexTree.isIndexUpdating(this)) {
                        Logger.notice(this, "A transfer is already running !");
-                       return 0;
+                       return false;
                }

                if (publicKey == null) {
                        Logger.error(this, "No public key !! Can't get the 
index !");
-                       return 0;
+                       return false;
                }

                String key;
@@ -786,17 +807,12 @@


                if (key.startsWith("USK")) {
-                       int negRev = FreenetURIHelper.getUSKRevision(key);
+                       int daRev = FreenetURIHelper.getUSKRevision(key);

-                       boolean fetchNeg = true;
-
-                       if (config != null && 
config.getValue("indexFetchNegative") != null)
-                               fetchNeg = 
Boolean.valueOf(config.getValue("indexFetchNegative")).booleanValue();
-
-                       if ((fetchNeg && negRev > 0)
-                           || (!fetchNeg && negRev < 0)) {
-                               negRev = -1 * negRev;
-                               key = FreenetURIHelper.changeUSKRevision(key, 
negRev, 0);
+                       if ((fetchingNegRev && daRev > 0)
+                           || (!fetchingNegRev && daRev < 0)) {
+                               daRev = -1 * daRev;
+                               key = FreenetURIHelper.changeUSKRevision(key, 
daRev, 0);
                        }
                }

@@ -821,14 +837,12 @@
                 */
                clientGet.start(queueManager);

-               if (tree != null)
-                       tree.addUpdatingIndex(this);
+               if (indexTree != null)
+                       indexTree.addUpdatingIndex(this);

                clientGet.addObserver(this);

-               this.addObserver(o);
-
-               return 1;
+               return true;
        }


@@ -851,6 +865,7 @@
                        FCPClientGet get = (FCPClientGet)o;

                        if (get.isFinished() && get.isSuccessful()) {
+                               get.deleteObserver(this);

                                String key = get.getFileKey();

@@ -873,6 +888,19 @@

                                        parser.loadXML(path);

+
+                                       if (!fetchingNegRev && mustFetchNegRev) 
{
+                                               final java.io.File fl = new 
java.io.File(path);
+                                               fl.delete();
+
+                                               setChanged();
+                                               notifyObservers();
+
+                                               fetchingNegRev = true;
+                                               realDownloadFromFreenet(-1);
+                                               return;
+                                       }
+
                                        boolean loadComm = true;

                                        if (config != null && 
config.getValue("indexFetchComments") != null)
@@ -890,6 +918,8 @@
                if (o instanceof FCPClientPut) {
                        /* TODO : check if it's successful, else merge if it's 
due to a collision */
                        if (((FCPClientPut)o).isFinished()) {
+                               ((FCPClientPut)o).deleteObserver(this);
+
                                if (indexTree != null)
                                        indexTree.removeUpdatingIndex(this);

@@ -960,8 +990,6 @@
                                final java.io.File fl = new java.io.File(path);
                                fl.delete();

-                               ((Observable)transfer).deleteObserver(this);
-
                                setChanged();
                                notifyObservers();
                        }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java        
2007-08-03 19:35:37 UTC (rev 14477)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java        
2007-08-03 20:14:10 UTC (rev 14478)
@@ -18,7 +18,6 @@

 import thaw.gui.WarningWindow;

-
 public class IndexConfigPanel implements ActionListener {
        private ConfigWindow configWindow;
        private Config config;

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java     2007-08-03 
19:35:37 UTC (rev 14477)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java     2007-08-03 
20:14:10 UTC (rev 14478)
@@ -299,7 +299,7 @@
                 * @see org.xml.sax.ContentHandler#startDocument()
                 */
                public void startDocument() throws SAXException {
-
+                       index.purgeIndex();
                }

                /**


Reply via email to