Author: toad
Date: 2008-06-19 23:27:27 +0000 (Thu, 19 Jun 2008)
New Revision: 20507

Modified:
   branches/db4o/freenet/src/freenet/support/io/FileUtil.java
   branches/db4o/freenet/src/freenet/support/io/FilenameGenerator.java
Log:
Having some problems with storing and canonicalising File's. :|

Modified: branches/db4o/freenet/src/freenet/support/io/FileUtil.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/io/FileUtil.java  2008-06-19 
23:24:43 UTC (rev 20506)
+++ branches/db4o/freenet/src/freenet/support/io/FileUtil.java  2008-06-19 
23:27:27 UTC (rev 20507)
@@ -71,9 +71,16 @@
        }

        public static File getCanonicalFile(File file) {
+               // Having some problems storing File's in db4o ...
+               // It would start up, and canonicalise a file with path 
"/var/lib/freenet-experimental/persistent-temp-24374"
+               // to 
/var/lib/freenet-experimental/var/lib/freenet-experimental/persistent-temp-24374
 
+               // (where /var/lib/freenet-experimental is the current working 
dir)
+               // Regenerating from path worked. So do that here.
+               // And yes, it's voodoo.
+               file = new File(file.getPath());
                File result;
                try {
-                       result = file.getCanonicalFile();
+                       result = file.getAbsoluteFile().getCanonicalFile();
                } catch (IOException e) {
                        result = file.getAbsoluteFile();
                }

Modified: branches/db4o/freenet/src/freenet/support/io/FilenameGenerator.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/io/FilenameGenerator.java 
2008-06-19 23:24:43 UTC (rev 20506)
+++ branches/db4o/freenet/src/freenet/support/io/FilenameGenerator.java 
2008-06-19 23:27:27 UTC (rev 20507)
@@ -118,9 +118,11 @@
                this.random = random;
                File oldDir = FileUtil.getCanonicalFile(tmpDir);
                File newDir = FileUtil.getCanonicalFile(dir);
+               System.err.println("Old: "+oldDir+" prefix "+this.prefix+" from 
"+tmpDir+" old path "+tmpDir.getPath()+" old parent "+tmpDir.getParent());
+               System.err.println("New: "+newDir+" prefix "+prefix+" from 
"+dir);
                if(oldDir.equals(newDir) && this.prefix.equals(prefix)) {
                        Logger.normal(this, "Initialised FilenameGenerator 
successfully - no change in dir and prefix: dir="+dir+" prefix="+prefix);
-               } else if(!oldDir.equals(newDir) && this.prefix.equals(prefix)) 
{
+               } else if((!oldDir.equals(newDir)) && 
this.prefix.equals(prefix)) {
                        if((!dir.exists()) && oldDir.renameTo(dir)) {
                                tmpDir = dir;
                                // This will interest the user, since they 
changed it.


Reply via email to