Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't SFTP PUT directory contents twice #230

Merged
merged 2 commits into from
Apr 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hidetake.groovy.ssh.session.transfer.put

import groovy.io.FileType

/**
* Represents a collection of SCP PUT instructions
* such as {@link File}, {@link StreamContent}, {@link EnterDirectory} or {@link LeaveDirectory}.
Expand Down Expand Up @@ -50,7 +52,7 @@ class Instructions implements Iterable {
if (path.directory) {
def children = []
children.add(new EnterDirectory(path.name))
path.eachFile { file -> children.addAll(forFileRecursive(file)) }
path.eachFile(FileType.FILES) { file -> children.addAll(forFileRecursive(file)) }
path.eachDir { dir -> children.addAll(forFileRecursive(dir)) }
children.add(LeaveDirectory.instance)
children
Expand All @@ -74,7 +76,7 @@ class Instructions implements Iterable {
private static Collection forFileWithFilterRecursive(File path, Closure<Boolean> filter) {
if (path.directory) {
def children = new ArrayDeque()
path.eachFile { file -> children.addAll(forFileWithFilterRecursive(file, filter)) }
path.eachFile(FileType.FILES) { file -> children.addAll(forFileWithFilterRecursive(file, filter)) }
path.eachDir { dir -> children.addAll(forFileWithFilterRecursive(dir, filter)) }
if (!children.empty) {
children.addFirst(new EnterDirectory(path.name))
Expand Down