private void copyDirectory(final JGitPathImpl source, final JGitPathImpl target) { final List<JGitPathImpl> directories = new ArrayList<JGitPathImpl>(); for (final Path path : newDirectoryStream(source, null)) { final JGitPathImpl gPath = toPathImpl(path); final Pair<PathType, ObjectId> pathResult = checkPath(gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath()); if (pathResult.getK1() == DIRECTORY) { directories.add(gPath); continue; } final JGitPathImpl gTarget = composePath(target, (JGitPathImpl) gPath.getFileName()); copyFile(gPath, gTarget); } for (final JGitPathImpl directory : directories) { createDirectory(composePath(target, (JGitPathImpl) directory.getFileName())); } }
private void copyDirectory(final JGitPathImpl source, final JGitPathImpl target, final CopyOption... options) { final List<JGitPathImpl> directories = new ArrayList<>(); for (final Path path : newDirectoryStream(source, null)) { final JGitPathImpl gPath = toPathImpl(path); final PathInfo pathResult = gPath.getFileSystem().getGit().getPathInfo(gPath.getRefTree(), gPath.getPath()); if (pathResult.getPathType() == DIRECTORY) { directories.add(gPath); continue; } final JGitPathImpl gTarget = composePath(target, (JGitPathImpl) gPath.getFileName()); copyFile(gPath, gTarget); } for (final JGitPathImpl directory : directories) { createDirectory(composePath(target, (JGitPathImpl) directory.getFileName())); } }
@Test public void testCreateDirectory() { final URI newRepo = URI.create("git://xcreatedir-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final JGitPathImpl path = (JGitPathImpl) provider.getPath(URI.create("git://master@xcreatedir-test-repo/some/path/to/")); final PathInfo result = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); assertThat(result.getPathType()).isEqualTo(PathType.NOT_FOUND); provider.createDirectory(path); final PathInfo resultAfter = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); assertThat(resultAfter.getPathType()).isEqualTo(PathType.DIRECTORY); final Path gitkeepPath = path.resolve(".gitkeep"); assertThat(provider.exists(gitkeepPath)).isEqualTo(true); try { provider.createDirectory(path); failBecauseExceptionWasNotThrown(FileAlreadyExistsException.class); } catch (FileAlreadyExistsException ignored) { } }
provider.createDirectory(dir1);
@Test public void testCreateDirectory() { final URI newRepo = URI.create("git://xcreatedir-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final JGitPathImpl path = (JGitPathImpl) provider.getPath(URI.create("git://master@xcreatedir-test-repo/some/path/to/")); final PathInfo result = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); assertThat(result.getPathType()).isEqualTo(PathType.NOT_FOUND); provider.createDirectory(path); final PathInfo resultAfter = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); assertThat(resultAfter.getPathType()).isEqualTo(PathType.DIRECTORY); final Path gitkeepPath = path.resolve(".gitkeep"); assertThat(provider.exists(gitkeepPath)).isEqualTo(true); try { provider.createDirectory(path); failBecauseExceptionWasNotThrown(FileAlreadyExistsException.class); } catch (FileAlreadyExistsException ignored) { } }
provider.createDirectory(dir1);
provider.createDirectory(crazyPath);
provider.createDirectory(crazyPath);