@@ -856,7 +856,7 @@ cmd specifies a command to exec. Valid commands are:
856
856
(defn- scp-send-command
857
857
" Send command to the specified output stream"
858
858
[^OutputStream out ^InputStream in ^String cmd-string]
859
- (.write out (.getBytes cmd-string))
859
+ (.write out (.getBytes ( str cmd-string " \n " ) ))
860
860
(.flush out)
861
861
(logging/tracef " Sent command %s" cmd-string)
862
862
(scp-receive-ack in)
@@ -882,22 +882,21 @@ cmd specifies a command to exec. Valid commands are:
882
882
883
883
(defn- scp-copy-file
884
884
" Send acknowledgement to the specified output stream"
885
- [send recv ^File file {:keys [mode buffer-size preserve]
885
+ [^OutputStream send ^InputStream recv ^File file {:keys [mode buffer-size preserve]
886
886
:or {mode 0644 buffer-size 1492 preserve false }}]
887
- ( logging/tracef " Sending %s " ( .getAbsolutePath file))
887
+
888
888
(when preserve
889
889
(scp-send-command
890
890
send recv
891
- (format " P %d 0 %d 0\n " (.lastModified file) (.lastModified file))))
891
+ (format " P%d 0 %d 0" (.lastModified file) (.lastModified file))))
892
892
(scp-send-command
893
893
send recv
894
- (format " C%04o %d %s\n " mode (.length file) (.getName file)))
895
- (with-open [fs ( FileInputStream. file)]
896
- (io/copy fs send :buffer-size buffer-size) )
894
+ (format " C%04o %d %s" mode (.length file) (.getName file)))
895
+ (logging/tracef " Sending %s " ( .getAbsolutePath file))
896
+ (io/copy file send :buffer-size buffer-size)
897
897
(scp-send-ack send)
898
- (logging/trace " Sent ACK after send" )
899
- (scp-receive-ack recv)
900
- (logging/trace " Received ACK after send" ))
898
+ (logging/trace " Receiving ACK after send" )
899
+ (scp-receive-ack recv))
901
900
902
901
(defn- scp-copy-dir
903
902
" Send acknowledgement to the specified output stream"
@@ -910,10 +909,7 @@ cmd specifies a command to exec. Valid commands are:
910
909
(cond
911
910
(.isFile file) (scp-copy-file send recv file options)
912
911
(.isDirectory file) (scp-copy-dir send recv file options)))
913
- (scp-send-ack send)
914
- (logging/trace " Sent ACK after send" )
915
- (scp-receive-ack recv)
916
- (logging/trace " Received ACK after send" ))
912
+ (scp-send-command send recv " E" ))
917
913
918
914
(defn- scp-files
919
915
[paths recursive]
@@ -1025,7 +1021,7 @@ cmd specifies a command to exec. Valid commands are:
1025
1021
(connect session))
1026
1022
(let [[^PipedInputStream in
1027
1023
^PipedOutputStream send] (streams-for-in )
1028
- cmd (format " scp %s -t %s" (:remote-flags opts " " ) remote-path)
1024
+ cmd (format " scp %s %s -t %s" (:remote-flags opts " " ) ( if recursive " -r " " " ) remote-path)
1029
1025
_ (logging/tracef " scp-to: %s" cmd)
1030
1026
{:keys [^ChannelExec channel ^PipedInputStream out-stream]}
1031
1027
(ssh-exec session cmd in :stream opts)
0 commit comments