Author: j16sdiz
Date: 2008-11-24 13:11:29 +0000 (Mon, 24 Nov 2008)
New Revision: 23838

Modified:
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/Node.java
Log:
display UserAlert for old bdbfile (bug 2722)

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-11-24 
12:55:01 UTC (rev 23837)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-11-24 
13:11:29 UTC (rev 23838)
@@ -723,6 +723,8 @@
 Node.storePreallocateLong=Preallocate space for datastore
 Node.storeSaltHashResizeOnStart=Resize store on node start (salt-hash only)
 Node.storeSaltHashResizeOnStartLong=Resize store on node start (salt-hash 
only). If this is true, the node will complete resizing the datastore during 
startup. This will complete much faster than doing it "on the fly", but on the 
other hand the node will not be available for some time while it completes the 
resize.
+Node.storeSaltHashMigratedShort=Datastore migration finished!
+Node.storeSaltHashMigrated=Datastore migration finished! You may now delete 
the old datastore files:
 Node.storeSize=Store size in bytes
 Node.storeSizeLong=Store size in bytes
 Node.storeType=Store type (LEAVE THIS ALONE)

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-11-24 12:55:01 UTC (rev 
23837)
+++ trunk/freenet/src/freenet/node/Node.java    2008-11-24 13:11:29 UTC (rev 
23838)
@@ -1731,6 +1731,106 @@
                        ((SaltedHashFreenetStore) 
pubKeyDatacache.getStore()).setUserAlertManager(clientCore.alerts);
                        ((SaltedHashFreenetStore) 
sskDatastore.getStore()).setUserAlertManager(clientCore.alerts);
                        ((SaltedHashFreenetStore) 
sskDatacache.getStore()).setUserAlertManager(clientCore.alerts);
+
+                       if (new File(storeDir, "chk" + suffix + 
".store").exists()
+                               || new File(storeDir, "chk" + suffix + 
".store.keys").exists()
+                               || new File(storeDir, "chk" + suffix + 
".store.lru").exists()
+                               || new File(storeDir, "chk" + suffix + 
".cache").exists()
+                               || new File(storeDir, "chk" + suffix + 
".cache.keys").exists()
+                               || new File(storeDir, "chk" + suffix + 
".cache.lru").exists()
+                               || new File(storeDir, "pubkey" + suffix + 
".store").exists()
+                               || new File(storeDir, "pubkey" + suffix + 
".store.keys").exists()
+                               || new File(storeDir, "pubkey" + suffix + 
".store.lru").exists()
+                               || new File(storeDir, "pubkey" + suffix + 
".cache").exists()
+                               || new File(storeDir, "pubkey" + suffix + 
".cache.keys").exists()
+                               || new File(storeDir, "pubkey" + suffix + 
".cache.lru").exists()
+                               || new File(storeDir, "ssk" + suffix + 
".store").exists()
+                               || new File(storeDir, "ssk" + suffix + 
".store.keys").exists()
+                               || new File(storeDir, "ssk" + suffix + 
".store.lru").exists()
+                               || new File(storeDir, "ssk" + suffix + 
".cache").exists()
+                               || new File(storeDir, "ssk" + suffix + 
".cache.keys").exists()
+                               || new File(storeDir, "ssk" + suffix + 
".cache.lru").exists()
+                               || new File(storeDir, "database" + 
suffix).exists()) {
+                               clientCore.alerts.register(new 
SimpleUserAlert(true, L10n.getString("Node.storeSaltHashMigratedShort"),
+                                       
L10n.getString("Node.storeSaltHashMigratedShort"), L10n
+                                               
.getString("Node.storeSaltHashMigratedShort"), UserAlert.MINOR) {
+                                       
+                                       @Override
+                                       public HTMLNode getHTMLText() {
+                                               HTMLNode div = new 
HTMLNode("div");
+                                               div.addChild("#", 
L10n.getString("Node.storeSaltHashMigrated"));
+                                               HTMLNode ul = 
div.addChild("ul");
+
+                                               for (String type : new String[] 
{ "chk", "pubkey", "ssk" })
+                                                       for (String storecache 
: new String[] { "store", "store.key", "store.lru" }) {
+                                                               File f = new 
File(storeDir, type + suffix + "." + storecache);
+                                                               if (f.exists())
+                                                                       
ul.addChild("li", f.getAbsolutePath());
+                                                       }
+                                               
+                                               File dbDir = new File(storeDir, 
"database" + suffix);
+                                               if (dbDir.exists())
+                                                       ul.addChild("li", 
dbDir.getAbsolutePath());
+                                               
+                                               return div;
+                                       }
+
+                                       @Override
+                                       public String getText() {               
                                
+                                               StringBuilder sb = new 
StringBuilder();
+                                               
sb.append(L10n.getString("Node.storeSaltHashMigrated") + " \n");
+                                               
+                                               for (String type : new String[] 
{ "chk", "pubkey", "ssk" })
+                                                       for (String storecache 
: new String[] { "store", "store.key", "store.lru" }) {
+                                                               File f = new 
File(storeDir, type + suffix + "." + storecache);
+                                               if (f.exists())
+                                                                       
sb.append(" - ");
+                                                               
sb.append(f.getAbsolutePath());
+                                                               sb.append("\n");
+                                               }
+                                               File dbDir = new File(storeDir, 
"database" + suffix);
+                                               if (dbDir.exists()) {
+                                                       sb.append(" - ");
+                                                       
sb.append(dbDir.getAbsolutePath());
+                                                       sb.append("\n");
+                                               }
+                                               
+                                               return sb.toString();
+                                       }
+
+                                       @Override
+                                       public boolean isValid() {
+                                               return new File(storeDir, "chk" 
+ suffix + ".store").exists()
+                                       || new File(storeDir, "chk" + suffix + 
".store.keys").exists()
+                                       || new File(storeDir, "chk" + suffix + 
".store.lru").exists()
+                                       || new File(storeDir, "chk" + suffix + 
".cache").exists()
+                                       || new File(storeDir, "chk" + suffix + 
".cache.keys").exists()
+                                       || new File(storeDir, "chk" + suffix + 
".cache.lru").exists()
+                                       || new File(storeDir, "pubkey" + suffix 
+ ".store").exists()
+                                       || new File(storeDir, "pubkey" + suffix 
+ ".store.keys").exists()
+                                       || new File(storeDir, "pubkey" + suffix 
+ ".store.lru").exists()
+                                       || new File(storeDir, "pubkey" + suffix 
+ ".cache").exists()
+                                       || new File(storeDir, "pubkey" + suffix 
+ ".cache.keys").exists()
+                                       || new File(storeDir, "pubkey" + suffix 
+ ".cache.lru").exists()
+                                       || new File(storeDir, "ssk" + suffix + 
".store").exists()
+                                       || new File(storeDir, "ssk" + suffix + 
".store.keys").exists()
+                                       || new File(storeDir, "ssk" + suffix + 
".store.lru").exists()
+                                       || new File(storeDir, "ssk" + suffix + 
".cache").exists()
+                                       || new File(storeDir, "ssk" + suffix + 
".cache.keys").exists()
+                                       || new File(storeDir, "ssk" + suffix + 
".cache.lru").exists()
+                                       || new File(storeDir, "database" + 
suffix).exists();
+                                       }
+                                       
+                                       @Override
+                                       public void onDismiss() {
+                                       }
+                                       
+                                       @Override
+                                       public boolean userCanDismiss() {
+                                               return true;
+                                       }
+                               });
+                       }
                }
                
                securityLevels.registerUserAlert(clientCore.alerts);

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to