Author: toad
Date: 2007-07-27 18:07:29 +0000 (Fri, 27 Jul 2007)
New Revision: 14390
Modified:
trunk/freenet/src/freenet/support/io/FilenameGenerator.java
Log:
toHexString produces an unsigned long! so we have to parse it with
Fields.hexToLong.
also logging.
Modified: trunk/freenet/src/freenet/support/io/FilenameGenerator.java
===================================================================
--- trunk/freenet/src/freenet/support/io/FilenameGenerator.java 2007-07-27
17:32:18 UTC (rev 14389)
+++ trunk/freenet/src/freenet/support/io/FilenameGenerator.java 2007-07-27
18:07:29 UTC (rev 14390)
@@ -6,6 +6,7 @@
import org.tanukisoftware.wrapper.WrapperManager;
import freenet.crypt.RandomSource;
+import freenet.support.Fields;
import freenet.support.Logger;
import freenet.support.TimeUtil;
@@ -86,12 +87,19 @@
}
public long getID(File file) {
-
if(!(FileUtil.getCanonicalFile(file.getParentFile()).equals(tmpDir))) return -1;
+
if(!(FileUtil.getCanonicalFile(file.getParentFile()).equals(tmpDir))) {
+ Logger.error(this, "Not the same dir:
parent="+FileUtil.getCanonicalFile(file.getParentFile())+" but tmpDir="+tmpDir);
+ return -1;
+ }
String name = file.getName();
- if(!name.startsWith(prefix)) return -1;
+ if(!name.startsWith(prefix)) {
+ Logger.error(this, "Does not start with prefix:
"+name+" prefix "+prefix);
+ return -1;
+ }
try {
- return Long.parseLong(name.substring(prefix.length()),
16);
+ return
Fields.hexToLong(name.substring(prefix.length()));
} catch (NumberFormatException e) {
+ Logger.error(this, "Cannot getID: "+e+" from
"+(name.substring(prefix.length())), e);
return -1;
}
}