Author: toad
Date: 2006-01-14 20:51:07 +0000 (Sat, 14 Jan 2006)
New Revision: 7858
Modified:
trunk/freenet/src/freenet/client/FileInserter.java
trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
trunk/freenet/src/freenet/client/InsertBlock.java
trunk/freenet/src/freenet/node/TextModeClientInterface.java
trunk/freenet/src/freenet/node/Version.java
Log:
354:
Support for inserting an SSK freesite in a single command (PUTSSKDIR).
Modified: trunk/freenet/src/freenet/client/FileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/FileInserter.java 2006-01-14 20:24:24 UTC
(rev 7857)
+++ trunk/freenet/src/freenet/client/FileInserter.java 2006-01-14 20:51:07 UTC
(rev 7858)
@@ -151,7 +151,7 @@
if(isSSK) {
// Insert as CHK
// Create metadata pointing to it (include the
clientMetadata if there is any).
- FreenetURI uri = run(new InsertBlock(block.data, new
ClientMetadata(), FreenetURI.EMPTY_CHK_URI), metadata, getCHKOnly, noRetries,
null);
+ FreenetURI uri = run(new InsertBlock(block.data, null,
FreenetURI.EMPTY_CHK_URI), metadata, getCHKOnly, noRetries, null);
Metadata m = new Metadata(Metadata.SIMPLE_REDIRECT,
uri, block.clientMetadata);
Bucket bucket;
try {
@@ -159,7 +159,7 @@
} catch (IOException e) {
throw new
InserterException(InserterException.INTERNAL_ERROR, e, isk.getURI());
}
- return run(new InsertBlock(bucket, new
ClientMetadata(), block.desiredURI), metadata, getCHKOnly, noRetries, null);
+ return run(new InsertBlock(bucket, null,
block.desiredURI), metadata, getCHKOnly, noRetries, null);
}
if(data.size() <= NodeCHK.BLOCK_SIZE) {
Modified: trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
===================================================================
--- trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
2006-01-14 20:24:24 UTC (rev 7857)
+++ trunk/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
2006-01-14 20:51:07 UTC (rev 7858)
@@ -129,7 +129,7 @@
throw new
InserterException(InserterException.INTERNAL_ERROR, e, null);
}
ClientKey k;
- InsertBlock block = new InsertBlock(b, new ClientMetadata(),
insertURI);
+ InsertBlock block = new InsertBlock(b, null, insertURI);
InserterContext context = new InserterContext(client,
bucketFactory, random, INSERT_RETRIES, CONSECUTIVE_RNFS_ASSUME_SUCCESS,
SPLITFILE_INSERT_THREADS,
SPLITFILE_BLOCKS_PER_SEGMENT, SPLITFILE_CHECK_BLOCKS_PER_SEGMENT,
globalEventProducer, insertStarter, cacheLocalRequests);
FileInserter i = new FileInserter(context);
Modified: trunk/freenet/src/freenet/client/InsertBlock.java
===================================================================
--- trunk/freenet/src/freenet/client/InsertBlock.java 2006-01-14 20:24:24 UTC
(rev 7857)
+++ trunk/freenet/src/freenet/client/InsertBlock.java 2006-01-14 20:51:07 UTC
(rev 7858)
@@ -14,7 +14,10 @@
public InsertBlock(Bucket data, ClientMetadata metadata, FreenetURI
desiredURI) {
this.data = data;
- clientMetadata = metadata;
+ if(metadata == null)
+ clientMetadata = new ClientMetadata();
+ else
+ clientMetadata = metadata;
this.desiredURI = desiredURI;
}
Modified: trunk/freenet/src/freenet/node/TextModeClientInterface.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-01-14
20:24:24 UTC (rev 7857)
+++ trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-01-14
20:51:07 UTC (rev 7858)
@@ -102,6 +102,7 @@
System.out.println("GETCHKDIR:<path>[#<defaultfile>] - Get the key
that would be returned if we'd put the entire directory from disk.");
System.out.println("MAKESSK - Create an SSK keypair.");
System.out.println("PUTSSK:<insert uri>;<url to redirect to> - Insert
an SSK redirect to a file already inserted.");
+ System.out.println("PUTSSKDIR:<insert uri>#<path>[#<defaultfile>] -
Insert an entire directory to an SSK.");
// System.out.println("PUBLISH:<name> - create a publish/subscribe
stream called <name>");
// System.out.println("PUSH:<name>:<text> - publish a single line of
text to the stream named");
// System.out.println("SUBSCRIBE:<key> - subscribe to a
publish/subscribe stream by key");
@@ -261,13 +262,18 @@
System.out.println("URI: "+uri);
////////////////////////////////////////////////////////////////////////////////
- } else if(uline.startsWith("PUTDIR:") || (getCHKOnly =
uline.startsWith("GETCHKDIR:"))) {
+ } else if(uline.startsWith("PUTDIR:") ||
(uline.startsWith("PUTSSKDIR")) || (getCHKOnly =
uline.startsWith("GETCHKDIR:"))) {
// TODO: Check for errors?
- if(getCHKOnly) {
+ boolean ssk = false;
+ if(uline.startsWith("PUTDIR:"))
+ line = line.substring("PUTDIR:".length());
+ else if(uline.startsWith("PUTSSKDIR:")) {
+ line = line.substring("PUTSSKDIR:".length());
+ ssk = true;
+ } else if(uline.startsWith("GETCHKDIR:"))
line = line.substring(("GETCHKDIR:").length());
- } else {
- line = line.substring("PUTDIR:".length());
- }
+ else
+ System.err.println("Impossible");
line = line.trim();
@@ -278,10 +284,20 @@
String defaultFile = null;
+ FreenetURI insertURI = FreenetURI.EMPTY_CHK_URI;
+
// set default file?
if (line.matches("^.*#.*$")) {
- defaultFile = line.split("#")[1];
- line = line.split("#")[0];
+ String[] split = line.split("#");
+ if(ssk) {
+ insertURI = new FreenetURI(split[0]);
+ line = split[1];
+ if(split.length > 2)
+ defaultFile = split[2];
+ } else {
+ defaultFile = split[1];
+ line = split[0];
+ }
}
HashMap bucketsByName =
@@ -300,8 +316,8 @@
FreenetURI uri;
try {
- uri =
client.insertManifest(FreenetURI.EMPTY_CHK_URI, bucketsByName, defaultFile);
- uri.addMetaStrings(new String[] { "" });
+ uri = client.insertManifest(insertURI,
bucketsByName, defaultFile);
+ uri = uri.addMetaStrings(new String[] { "" });
System.out.println("=======================================================");
System.out.println("URI: "+uri);
System.out.println("=======================================================");
@@ -309,8 +325,8 @@
System.out.println("Finished insert but: "+e.getMessage());
if(e.uri != null) {
uri = e.uri;
- uri.addMetaStrings(new String[] { "" });
- System.out.println("URI would have been: "+e.uri);
+ uri = uri.addMetaStrings(new String[] { "" });
+ System.out.println("URI would have been: "+uri);
}
if(e.errorCodes != null) {
System.out.println("Splitfile errors breakdown:");
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-01-14 20:24:24 UTC (rev
7857)
+++ trunk/freenet/src/freenet/node/Version.java 2006-01-14 20:51:07 UTC (rev
7858)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- public static final int buildNumber = 353;
+ public static final int buildNumber = 354;
/** Oldest build of Fred we will talk to */
public static final int lastGoodBuild = 348;