Author: toad
Date: 2007-04-13 18:28:32 +0000 (Fri, 13 Apr 2007)
New Revision: 12647
Modified:
trunk/freenet/src/freenet/clients/http/QueueToadlet.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/node/fcp/ClientPut.java
Log:
<mario69> a tiny bugreport: typing /tmp/blah/blah into 'File' field of Insert
File form and pressing enter will happily make an entry in the upload queue. Of
course the /tmp/blah.... does not exist.
Modified: trunk/freenet/src/freenet/clients/http/QueueToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2007-04-13
16:56:32 UTC (rev 12646)
+++ trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2007-04-13
18:28:32 UTC (rev 12647)
@@ -4,6 +4,7 @@
package freenet.clients.http;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
@@ -249,6 +250,9 @@
} catch (NotAllowedException e) {
this.writeError(L10n.getString("QueueToadlet.errorAccessDenied"),
L10n.getString("QueueToadlet.errorAccessDeniedFile", new String[]{ "file" },
new String[]{ file.getFilename() }), ctx);
return;
+ } catch (FileNotFoundException e) {
+
this.writeError(L10n.getString("QueueToadlet.errorNoFileOrCannotRead"),
L10n.getString("QueueToadlet.errorAccessDeniedFile", new String[]{ "file" },
new String[]{ file.getFilename() }), ctx);
+ return;
}
writePermanentRedirect(ctx, "Done", "/queue/");
return;
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-04-13
16:56:32 UTC (rev 12646)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-04-13
18:28:32 UTC (rev 12647)
@@ -67,6 +67,7 @@
QueueToadlet.persistenceNone=none
QueueToadlet.errorAccessDenied=Error: Access Denied!
QueueToadlet.errorAccessDeniedFile=The current configuration of the node
prohibits you from uploading the file "${file}".
+QueueToadlet.errorNoFileOrCannotRead=The file does not exist or it cannot be
read
QueueToadlet.errorNoKey=No key specified to download
QueueToadlet.errorNoKeyToD=You did not specify a key to download.
QueueToadlet.errorInvalidURI=Invalid URI
Modified: trunk/freenet/src/freenet/node/fcp/ClientPut.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientPut.java 2007-04-13 16:56:32 UTC
(rev 12646)
+++ trunk/freenet/src/freenet/node/fcp/ClientPut.java 2007-04-13 18:28:32 UTC
(rev 12647)
@@ -4,6 +4,7 @@
package freenet.node.fcp;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import freenet.client.ClientMetadata;
@@ -80,15 +81,18 @@
* UPLOAD_FROM_REDIRECT)
* @throws IdentifierCollisionException
* @throws NotAllowedException
+ * @throws FileNotFoundException
*/
public ClientPut(FCPClient globalClient, FreenetURI uri, String
identifier, int verbosity,
short priorityClass, short persistenceType, String
clientToken, boolean getCHKOnly,
boolean dontCompress, int maxRetries, short
uploadFromType, File origFilename, String contentType,
- Bucket data, FreenetURI redirectTarget, String
targetFilename, boolean earlyEncode) throws IdentifierCollisionException,
NotAllowedException {
+ Bucket data, FreenetURI redirectTarget, String
targetFilename, boolean earlyEncode) throws IdentifierCollisionException,
NotAllowedException, FileNotFoundException {
super(uri, identifier, verbosity, null, globalClient,
priorityClass, persistenceType, null, true, getCHKOnly, dontCompress,
maxRetries, earlyEncode);
if(uploadFromType == ClientPutMessage.UPLOAD_FROM_DISK) {
if(!globalClient.core.allowUploadFrom(origFilename))
throw new NotAllowedException();
+ if(!(origFilename.exists() && origFilename.canRead()))
+ throw new FileNotFoundException();
}
logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.targetFilename = targetFilename;