Skip to content

Commit

Permalink
Merge pull request #230 from amake/put-duplication
Browse files Browse the repository at this point in the history
Don't SFTP PUT directory contents twice
  • Loading branch information
int128 authored Apr 21, 2017
2 parents 2ac4635 + 19ede5f commit 5f05e65
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit 5f05e65

Please sign in to comment.