You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-commits@incubator.apache.org by ng...@apache.org on 2007/09/11 20:08:32 UTC
svn commit: r574682 - in /incubator/ftpserver/trunk/core/src:
java/org/apache/ftpserver/command/STOU.java
test/org/apache/ftpserver/clienttests/StoreTest.java
Author: ngn
Date: Tue Sep 11 13:08:32 2007
New Revision: 574682
URL: http://svn.apache.org/viewvc?rev=574682&view=rev
Log:
Fixed broken STOU command when a full file path is provided as an argument (FTPSERVER-107)
Modified:
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java
incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java?rev=574682&r1=574681&r2=574682&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STOU.java Tue Sep 11 13:08:32 2007
@@ -86,18 +86,23 @@
return;
}
- String dirName = request.getArgument();
-
- String filePrefix;
- if(dirName == null) {
- filePrefix = "ftp.dat";
- } else {
- filePrefix = dirName + "/ftp.dat";
- }
+ String pathName = request.getArgument();
// get filenames
FileObject file = null;
try {
+ String filePrefix;
+ if(pathName == null) {
+ filePrefix = "ftp.dat";
+ } else {
+ FileObject dir = session.getFileSystemView().getFileObject(pathName);
+ if(dir.isDirectory()) {
+ filePrefix = pathName + "/ftp.dat";
+ } else {
+ filePrefix = pathName;
+ }
+ }
+
file = session.getFileSystemView().getFileObject(filePrefix);
if(file != null) {
file = getUniqueFile(connection, session, file);
@@ -106,6 +111,7 @@
catch(Exception ex) {
LOG.debug("Exception getting file object", ex);
}
+
if(file == null) {
out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "STOU", null));
return;
Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java?rev=574682&r1=574681&r2=574682&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java (original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java Tue Sep 11 13:08:32 2007
@@ -155,6 +155,16 @@
doAssertOfUniqueFile(client, ROOT_DIR);
}
+ public void testStoreUniqueWithCompletePath() throws Exception {
+ TEST_DIR.mkdirs();
+ File existingFile = new File(TEST_DIR, "existingFile.txt");
+ existingFile.createNewFile();
+
+ assertTrue(client.storeUniqueFile("foo/bar/existingFile.txt", new ByteArrayInputStream(testData)));
+
+ doAssertOfUniqueFile(client, ROOT_DIR);
+ }
+
public void testStoreUniqueWithDirectory() throws Exception {
TEST_DIR.mkdirs();