Author: toad
Date: 2008-01-17 23:06:06 +0000 (Thu, 17 Jan 2008)
New Revision: 17118
Modified:
trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java
trunk/freenet/src/freenet/clients/http/QueueToadlet.java
Log:
Insert directories from /files/ too!
Modified: trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java
2008-01-17 22:44:32 UTC (rev 17117)
+++ trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java
2008-01-17 23:06:06 UTC (rev 17118)
@@ -124,11 +124,18 @@
File currentFile = files[fileIndex];
HTMLNode fileRow = listingTable.addChild("tr");
if (currentFile.isDirectory()) {
- fileRow.addChild("td");
if (currentFile.canRead()) {
+ HTMLNode cellNode =
fileRow.addChild("td");
+ fileRow.addChild("td");
+ HTMLNode formNode =
toadletContext.addFormChild(cellNode, "/queue/", "insertLocalFileForm");
+ formNode.addChild("input", new
String[] { "type", "name", "value" }, new String[] { "hidden", "filename",
currentFile.getAbsolutePath() });
+ formNode.addChild("input", new
String[] { "type", "name", "value" }, new String[] { "submit",
"insert-local-dir", l10n("insert")});
+ if(furi != null)
+
formNode.addChild("input", new String[] { "type", "name", "value" }, new
String[] { "hidden", "key", furi.toACIIString() });
HTMLNode directoryCellNode =
fileRow.addChild("td");
directoryCellNode.addChild("a",
"href", "?path=" +
URLEncoder.encode(currentFile.getAbsolutePath(),false)+extra,
currentFile.getName());
} else {
+ fileRow.addChild("td");
fileRow.addChild("td", "class",
"unreadable-file", currentFile.getName());
}
fileRow.addChild("td");
Modified: trunk/freenet/src/freenet/clients/http/QueueToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2008-01-17
22:44:32 UTC (rev 17117)
+++ trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2008-01-17
23:06:06 UTC (rev 17118)
@@ -291,6 +291,31 @@
}
writePermanentRedirect(ctx, "Done", "/queue/");
return;
+ } else if (request.isPartSet("insert-local-dir")) {
+ String filename =
request.getPartAsString("filename", MAX_FILENAME_LENGTH);
+ if(logMINOR) Logger.minor(this, "Inserting
local directory: "+filename);
+ File file = new File(filename);
+ String identifier = file.getName() + "-fred-" +
System.currentTimeMillis();
+ FreenetURI furi = new FreenetURI("CHK@");
+ String key = request.getPartAsString("key",
128);
+ if(key != null) {
+ try {
+ furi = new FreenetURI(key);
+ } catch (MalformedURLException e) {
+
writeError(L10n.getString("QueueToadlet.errorInvalidURI"),
L10n.getString("QueueToadlet.errorInvalidURIToU"), ctx);
+ return;
+ }
+ }
+ try {
+ ClientPutDir clientPutDir = new
ClientPutDir(fcp.getGlobalClient(), furi, identifier, Integer.MAX_VALUE,
RequestStarter.BULK_SPLITFILE_PRIORITY_CLASS, ClientRequest.PERSIST_FOREVER,
null, false, false, -1, file, null, false, true, false);
+ if(logMINOR) Logger.minor(this,
"Started global request to insert dir "+file+" to "+furi+" as "+identifier);
+ clientPutDir.start();
+ fcp.forceStorePersistentRequests();
+ } catch (IdentifierCollisionException e) {
+ e.printStackTrace();
+ }
+ writePermanentRedirect(ctx, "Done", "/queue/");
+ return;
} else if (request.isPartSet("get")) {
String identifier =
request.getPartAsString("identifier", MAX_IDENTIFIER_LENGTH);
ClientRequest[] clientRequests =
fcp.getGlobalRequests();