Author: toad
Date: 2007-05-18 22:56:21 +0000 (Fri, 18 May 2007)
New Revision: 13268
Modified:
trunk/freenet/src/freenet/node/fcp/DataCarryingMessage.java
trunk/freenet/src/freenet/node/fcp/DirectDirPutFile.java
Log:
Allow inserting an empty file
Modified: trunk/freenet/src/freenet/node/fcp/DataCarryingMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/DataCarryingMessage.java 2007-05-18
20:54:53 UTC (rev 13267)
+++ trunk/freenet/src/freenet/node/fcp/DataCarryingMessage.java 2007-05-18
22:56:21 UTC (rev 13268)
@@ -11,6 +11,7 @@
import freenet.support.api.Bucket;
import freenet.support.api.BucketFactory;
import freenet.support.io.BucketTools;
+import freenet.support.io.NullBucket;
public abstract class DataCarryingMessage extends BaseDataCarryingMessage {
@@ -34,7 +35,10 @@
long len = dataLength();
if(len < 0)
throw new IllegalArgumentException("Invalid length:
"+len);
- if(len == 0) return;
+ if(len == 0) {
+ bucket = new NullBucket();
+ return;
+ }
Bucket tempBucket;
try {
tempBucket = createBucket(bf, len, server);
Modified: trunk/freenet/src/freenet/node/fcp/DirectDirPutFile.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/DirectDirPutFile.java 2007-05-18
20:54:53 UTC (rev 13267)
+++ trunk/freenet/src/freenet/node/fcp/DirectDirPutFile.java 2007-05-18
22:56:21 UTC (rev 13268)
@@ -8,6 +8,7 @@
import freenet.support.api.Bucket;
import freenet.support.api.BucketFactory;
import freenet.support.io.BucketTools;
+import freenet.support.io.NullBucket;
/**
* Specialized DirPutFile for direct uploads.
@@ -28,7 +29,10 @@
throw new
MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Could not
parse DataLength: "+e.toString(), identifier, global);
}
try {
- data = bf.makeBucket(length);
+ if(length == 0)
+ data = new NullBucket();
+ else
+ data = bf.makeBucket(length);
} catch (IOException e) {
throw new
MessageInvalidException(ProtocolErrorMessage.INTERNAL_ERROR, "Internal error:
could not allocate temp bucket: "+e.toString(), identifier, global);
}