Skip to content

Commit

Permalink
Fix #6339.
Browse files Browse the repository at this point in the history
Former-commit-id: 802059a29fba0aab9c304c335b6be01413caccde
  • Loading branch information
dkocher committed Feb 29, 2016
1 parent 63b323a commit 2bd84e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
7 changes: 4 additions & 3 deletions ftp/src/main/java/ch/cyberduck/core/ftp/FTPDeleteFeature.java
Expand Up @@ -25,9 +25,6 @@
import java.io.IOException;
import java.util.List;

/**
* @version $Id$
*/
public class FTPDeleteFeature implements Delete {

private FTPSession session;
Expand All @@ -47,6 +44,10 @@ public void delete(final List<Path> files, final LoginCallback prompt, final Cal
}
}
else if(file.isDirectory()) {
// Change working directory to parent
if(!session.getClient().changeWorkingDirectory(file.getParent().getAbsolute())) {
throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString());
}
if(!session.getClient().removeDirectory(file.getAbsolute())) {
throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString());
}
Expand Down
20 changes: 17 additions & 3 deletions ftp/src/test/java/ch/cyberduck/core/ftp/FTPDeleteFeatureTest.java
Expand Up @@ -37,9 +37,6 @@
import java.util.EnumSet;
import java.util.UUID;

/**
* @version $Id$
*/
@Category(IntegrationTest.class)
public class FTPDeleteFeatureTest {

Expand All @@ -58,4 +55,21 @@ public void delete(final Path file) {
}
});
}

@Test
public void testDeleteDirectory() throws Exception {
final Host host = new Host(new FTPTLSProtocol(), "test.cyberduck.ch", new Credentials(
System.getProperties().getProperty("ftp.user"), System.getProperties().getProperty("ftp.password")
));
final FTPSession session = new FTPSession(host);
session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
new FTPDirectoryFeature(session).mkdir(test);
new FTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.Callback() {
@Override
public void delete(final Path file) {
}
});
}
}

0 comments on commit 2bd84e9

Please sign in to comment.