public FileAttributes statExistence(String path) throws IOException { try { return engine.stat(path); } catch (SFTPException sftpe) { if (sftpe.getStatusCode() == Response.StatusCode.NO_SUCH_FILE) { return null; } else { throw sftpe; } } }
private boolean isDirectory(final String remote) throws IOException { try { FileAttributes attrs = engine.stat(remote); return attrs.getMode().getType() == FileMode.Type.DIRECTORY; } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("isDir: {} does not exist", remote); return false; } else { throw e; } } }
private String prepareFile(final LocalSourceFile local, final String remote) throws IOException { final FileAttributes attrs; try { attrs = engine.stat(remote); } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("probeFile: {} does not exist", remote); return remote; } else throw e; } if (attrs.getMode().getType() == FileMode.Type.DIRECTORY) { throw new IOException("Trying to upload file " + local.getName() + " to path " + remote + " but that is a directory"); } else { log.debug("probeFile: {} is a {} file that will be replaced", remote, attrs.getMode().getType()); return remote; } }
private boolean makeDirIfNotExists(final String remote) throws IOException { try { FileAttributes attrs = engine.stat(remote); if (attrs.getMode().getType() != FileMode.Type.DIRECTORY) { throw new IOException(remote + " exists and should be a directory, but was a " + attrs.getMode().getType()); } // Was not created, but existed. return false; } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("makeDir: {} does not exist, creating", remote); engine.makeDir(remote); return true; } else { throw e; } } }
public FileAttributes statExistence(String path) throws IOException { try { return engine.stat(path); } catch (SFTPException sftpe) { if (sftpe.getStatusCode() == Response.StatusCode.NO_SUCH_FILE) { return null; } else { throw sftpe; } } }
public FileAttributes statExistence(String path) throws IOException { try { return engine.stat(path); } catch (SFTPException sftpe) { if (sftpe.getStatusCode() == Response.StatusCode.NO_SUCH_FILE) { return null; } else { throw sftpe; } } }
private boolean isDirectory(final String remote) throws IOException { try { FileAttributes attrs = engine.stat(remote); return attrs.getMode().getType() == FileMode.Type.DIRECTORY; } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("isDir: {} does not exist", remote); return false; } else { throw e; } } }
private String prepareFile(final LocalSourceFile local, final String remote) throws IOException { final FileAttributes attrs; try { attrs = engine.stat(remote); } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("probeFile: {} does not exist", remote); return remote; } else throw e; } if (attrs.getMode().getType() == FileMode.Type.DIRECTORY) { throw new IOException("Trying to upload file " + local.getName() + " to path " + remote + " but that is a directory"); } else { log.debug("probeFile: {} is a {} file that will be replaced", remote, attrs.getMode().getType()); return remote; } }
private boolean makeDirIfNotExists(final String remote) throws IOException { try { FileAttributes attrs = engine.stat(remote); if (attrs.getMode().getType() != FileMode.Type.DIRECTORY) { throw new IOException(remote + " exists and should be a directory, but was a " + attrs.getMode().getType()); } // Was not created, but existed. return false; } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("makeDir: {} does not exist, creating", remote); engine.makeDir(remote); return true; } else { throw e; } } }
private String prepareFile(final LocalSourceFile local, final String remote) throws IOException { final FileAttributes attrs; try { attrs = engine.stat(remote); } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("probeFile: {} does not exist", remote); return remote; } else throw e; } if (attrs.getMode().getType() == FileMode.Type.DIRECTORY) { log.debug("probeFile: {} was directory, path adjusted for {}", remote, local.getName()); return engine.getPathHelper().adjustForParent(remote, local.getName()); } else { log.debug("probeFile: {} is a {} file that will be replaced", remote, attrs.getMode().getType()); return remote; } }
final Response.StatusCode code = failure.getStatusCode(); switch(code) { case UNKNOWN:
private String prepareDir(final LocalSourceFile local, final String remote) throws IOException { final FileAttributes attrs; try { attrs = engine.stat(remote); } catch (SFTPException e) { if (e.getStatusCode() == StatusCode.NO_SUCH_FILE) { log.debug("probeDir: {} does not exist, creating", remote); engine.makeDir(remote); return remote; } else throw e; } if (attrs.getMode().getType() == FileMode.Type.DIRECTORY) if (engine.getPathHelper().getComponents(remote).getName().equals(local.getName())) { log.debug("probeDir: {} already exists", remote); return remote; } else { log.debug("probeDir: {} already exists, path adjusted for {}", remote, local.getName()); return prepareDir(local, engine.getPathHelper().adjustForParent(remote, local.getName())); } else throw new IOException(attrs.getMode().getType() + " file already exists at " + remote); }