Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Commit a598d49

Browse files
committed
fixing sftp
1 parent 7373677 commit a598d49

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/ShellKit/Executors/SSHExecutor.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class SSHExecutor: Executor {
1515

1616
let eventLoop: EventLoop
1717
let ssh: SSH
18+
var sftp: SFTP?
1819

1920
let workDir: String
2021

@@ -112,10 +113,10 @@ public class SSHExecutor: Executor {
112113
let promise = eventLoop.makePromise(of: Void.self)
113114
DispatchQueue.global(qos: .background).async {
114115
do {
115-
try autoreleasepool {
116-
let sftp: SFTP? = try self.ssh.openSftp()
117-
try sftp?.upload(data: data, remotePath: path)
116+
if self.sftp == nil {
117+
self.sftp = try self.ssh.openSftp()
118118
}
119+
try self.sftp?.upload(data: data, remotePath: path)
119120
self.eventLoop.execute {
120121
promise.succeed(Void())
121122
}

0 commit comments

Comments
 (0)