public FileMode.Type getType() { return mode.getType(); }
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; } } }
@Test public void shouldDetectDirectoryWithLinuxMask() { FileMode fileMode = new FileMode(040755); assertThat(fileMode.toString(), equalTo("[mask=40755]")); assertThat(fileMode.getType(), equalTo(FileMode.Type.DIRECTORY)); }
@Test public void shouldDetectDirectoryWithAixUnixMask() { FileMode fileMode = new FileMode(0240755); assertThat(fileMode.toString(), equalTo("[mask=240755]")); assertThat(fileMode.getType(), equalTo(FileMode.Type.DIRECTORY)); } }
public FileMode.Type getType() { return mode.getType(); }
public FileMode.Type getType() { return mode.getType(); }
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; } }
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); }