Author: toad
Date: 2009-02-26 18:25:43 +0000 (Thu, 26 Feb 2009)
New Revision: 25836

Modified:
   trunk/freenet/
   trunk/freenet/src/freenet/client/
   trunk/freenet/src/freenet/client/Metadata.java
   trunk/freenet/src/freenet/client/MetadataUnresolvedException.java
   trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
Log:
Merge 25356 from db4o. Hopefully this will help to fix bug #2486.



Property changes on: trunk/freenet
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/db4o:25594
/branches/db4o/freenet:24785,25282,25290,25332,25351-25352,25355,25479,25488,25540,25594
   + /branches/db4o:25594
/branches/db4o/freenet:24785,25282,25290,25332,25351-25352,25355-25356,25479,25488,25540,25594


Property changes on: trunk/freenet/src/freenet/client
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/branches/db4o/freenet/src/freenet/client:24785,25282,25290,25332,25351-25353,25355,25479,25488,25540,25594
/branches/db4o/src/freenet/client:25594
   + 
/branches/db4o/freenet/src/freenet/client:24785,25282,25290,25332,25351-25353,25355-25356,25479,25488,25540,25594
/branches/db4o/src/freenet/client:25594

Modified: trunk/freenet/src/freenet/client/Metadata.java
===================================================================
--- trunk/freenet/src/freenet/client/Metadata.java      2009-02-26 18:22:20 UTC 
(rev 25835)
+++ trunk/freenet/src/freenet/client/Metadata.java      2009-02-26 18:25:43 UTC 
(rev 25836)
@@ -114,6 +114,7 @@
        short splitfileAlgorithm;
        static public final short SPLITFILE_NONREDUNDANT = 0;
        static public final short SPLITFILE_ONION_STANDARD = 1;
+       public static final int MAX_SIZE_IN_MANIFEST = Short.MAX_VALUE;
        
        /** Splitfile parameters */
        byte[] splitfileParams;
@@ -840,7 +841,7 @@
                                Metadata meta = (Metadata) 
manifestEntries.get(name);
                                try {
                                        byte[] data = meta.writeToByteArray();
-                                       if(data.length > Short.MAX_VALUE) {
+                                       if(data.length > MAX_SIZE_IN_MANIFEST) {
                                                FreenetURI uri = 
meta.resolvedURI;
                                                if(uri != null) {
                                                        meta = new 
Metadata(SIMPLE_REDIRECT, null, null, uri, null);

Modified: trunk/freenet/src/freenet/client/MetadataUnresolvedException.java
===================================================================
--- trunk/freenet/src/freenet/client/MetadataUnresolvedException.java   
2009-02-26 18:22:20 UTC (rev 25835)
+++ trunk/freenet/src/freenet/client/MetadataUnresolvedException.java   
2009-02-26 18:25:43 UTC (rev 25836)
@@ -8,7 +8,7 @@
 
        public final Metadata[] mustResolve;
        
-       MetadataUnresolvedException(Metadata[] mustResolve, String message) {
+       public MetadataUnresolvedException(Metadata[] mustResolve, String 
message) {
                super(message);
                this.mustResolve = mustResolve;
        }

Modified: trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java    
2009-02-26 18:22:20 UTC (rev 25835)
+++ trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java    
2009-02-26 18:25:43 UTC (rev 25836)
@@ -148,7 +148,24 @@
                                }
                        }
                        if(allMetadatas) {
+                               // Will resolve etc.
                                gotAllMetadata();
+                       } else {
+                               // Resolve now to speed up the insert.
+                               try {
+                                       byte[] buf = m.writeToByteArray();
+                                       if(buf.length > 
Metadata.MAX_SIZE_IN_MANIFEST)
+                                               throw new 
MetadataUnresolvedException(new Metadata[] { m }, "Too big");
+                               } catch (MetadataUnresolvedException e) {
+                                       try {
+                                               resolve(e);
+                                       } catch (IOException e1) {
+                                               fail(new 
InsertException(InsertException.BUCKET_ERROR, e1, null));
+                                               return;
+                                       } catch (InsertException e1) {
+                                               fail(e1);
+                                       }
+                               }
                        }
                }
 
@@ -561,7 +578,8 @@
        }
 
        /**
-        * Start inserts for unresolved (too big) Metadata's.
+        * Start inserts for unresolved (too big) Metadata's. Eventually these 
will call back with an onEncode(),
+        * meaning they have the CHK, and we can progress to 
resolveAndStartBase(). 
         * @param e
         * @return
         * @throws InsertException

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

Reply via email to