@Override public void deleteDirectory(final FlowFile flowFile, final String remoteDirectoryName) throws IOException { try { sftp.rm(remoteDirectoryName); } catch (final SftpException e) { throw new IOException("Failed to delete remote directory " + remoteDirectoryName, e); } }
@Override public boolean delete(Path path) throws IOException { ChannelSftp channel = null; try { channel = this.fsHelper.getSftpChannel(); if (getFileStatus(path).isDirectory()) { channel.rmdir(HadoopUtils.toUriPath(path)); } else { channel.rm(HadoopUtils.toUriPath(path)); } } catch (SftpException e) { throw new IOException(e); } finally { safeDisconnect(channel); } return true; }
public void delete( String file ) throws KettleJobException { try { c.rm( file ); } catch ( SftpException e ) { throw new KettleJobException( e ); } }
boolean status = true; try { channel.rm(pathName); } catch (SftpException e) { status = false;
/** * 删除文件 * * @param filePath 要删除的文件绝对路径 */ @Override public boolean delFile(String filePath) { try { channel.rm(filePath); } catch (SftpException e) { throw new JschRuntimeException(e); } return true; }
void delete(String path, boolean isDirectory) throws IOException { try { if (isDirectory) { channel.rmdir(path); } else { channel.rm(path); } } catch (SftpException e) { throw exceptionFactory.createDeleteException(path, e, isDirectory); } }
/** * 删除文件 * * @param filePath 要删除的文件绝对路径 */ @Override public boolean delFile(String filePath) { try { channel.rm(filePath); } catch (SftpException e) { throw new JschRuntimeException(e); } return true; }
public void delete(ProtocolFile file) throws ProtocolException { try { if (file.isDir()) { sftpChannel.rmdir(file.getPath()); } else { sftpChannel.rm(file.getPath()); } } catch (Exception e) { throw new ProtocolException("Failed to download file '" + file + "' : " + e.getMessage(), e); } }
@Override public void deleteFile(final FlowFile flowFile, final String path, final String remoteFileName) throws IOException { final String fullPath = (path == null) ? remoteFileName : (path.endsWith("/")) ? path + remoteFileName : path + "/" + remoteFileName; try { sftp.rm(fullPath); } catch (final SftpException e) { switch (e.id) { case ChannelSftp.SSH_FX_NO_SUCH_FILE: throw new FileNotFoundException("Could not find file " + remoteFileName + " to remove from remote SFTP Server"); case ChannelSftp.SSH_FX_PERMISSION_DENIED: throw new PermissionDeniedException("Insufficient permissions to delete file " + remoteFileName + " from remote SFTP Server", e); default: throw new IOException("Failed to delete remote file " + fullPath, e); } } }
} catch (final SftpException e) { try { sftp.rm(tempPath); throw new IOException("Failed to rename dot-file to " + fullPath + " due to " + e, e); } catch (final SftpException e1) {
@Override public boolean remove(String path) throws IOException { Assert.state(this.channel != null, "session is not connected"); try { this.channel.rm(path); return true; } catch (SftpException e) { throw new NestedIOException("Failed to remove file.", e); } }
@Override public void rm(String path) throws IOException { map(() -> { ftp.rm(path); return null; }); }
@Override public void rmdir(String path) throws IOException { map(() -> { ftp.rm(path); return null; }); }
/** * 删除多个文件 * @param files * @throws SftpException */ public void deleteFile(String...files) throws SftpException{ for(String file:files) cs.rm(file); }
@Override public void deleteDirectory(final FlowFile flowFile, final String remoteDirectoryName) throws IOException { try { sftp.rm(remoteDirectoryName); } catch (final SftpException e) { throw new IOException("Failed to delete remote directory " + remoteDirectoryName, e); } }
@Override public void rmdir(String path) throws IOException { map(() -> { ftp.rm(path); return null; }); }
@Override public boolean remove(String path) throws IOException { Assert.state(this.channel != null, "session is not connected"); try { this.channel.rm(path); return true; } catch (SftpException e) { throw new NestedIOException("Failed to remove file.", e); } }
public synchronized boolean deleteFile(String name) throws GenericFileOperationFailedException { LOG.debug("Deleting file: {}", name); try { reconnectIfNecessary(); channel.rm(name); return true; } catch (SftpException e) { LOG.debug("Cannot delete file: {}", name, e); throw new GenericFileOperationFailedException("Cannot delete file: " + name, e); } }
public void rm(String path) throws SshException { try { channel.rm(path); } catch (SftpException e) { throw new net.sf.sshapi.sftp.SftpException(e.id, e.getLocalizedMessage(), e); } }
@Test public void shouldDeleteRemoteFile() throws SftpException { FTPFile file = new FTPFile("file.name", 0, "/some/directory", 0, false); sftpConnection.deleteRemoteFile(file); verify(mockChannel).rm("/some/directory/file.name"); }