Author: toad
Date: 2006-08-23 19:48:15 +0000 (Wed, 23 Aug 2006)
New Revision: 10246

Modified:
   trunk/freenet/src/freenet/node/fcp/ClientGet.java
Log:
Fix getBucket() when downloading to disk.

Modified: trunk/freenet/src/freenet/node/fcp/ClientGet.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientGet.java   2006-08-23 18:52:15 UTC 
(rev 10245)
+++ trunk/freenet/src/freenet/node/fcp/ClientGet.java   2006-08-23 19:48:15 UTC 
(rev 10246)
@@ -274,6 +274,10 @@
                // FIXME I don't think this is a problem in this case...? (Disk 
write while locked..)
                AllDataMessage adm = null;
                synchronized(this) {
+                       if(succeeded) {
+                               Logger.error(this, "onSuccess called twice for 
"+this+" ("+identifier+")");
+                               return; // We might be called twice; ignore it 
if so.
+                       }
                        if(returnType == ClientGetMessage.RETURN_TYPE_DIRECT) {
                                // Send all the data at once
                                // FIXME there should be other options
@@ -574,10 +578,16 @@
         *         isn’t applicable
         */
        public Bucket getBucket() {
-               return returnBucket;
+               synchronized(this) {
+                       if(targetFile != null) {
+                               if(succeeded || tempFile == null)
+                                       return new FileBucket(targetFile, 
false, false, false, false);
+                               else
+                                       return new FileBucket(tempFile, false, 
false, false, false);
+                       } else return returnBucket;
+               }
        }

-
        public void onFetchable(BaseClientPutter state) {
                // Ignore, we don't insert
        }


Reply via email to