Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Created October 9, 2024 15:06
Show Gist options
  • Save robertmryan/0cb300bdbcd560cfa999b817e8f71999 to your computer and use it in GitHub Desktop.
Save robertmryan/0cb300bdbcd560cfa999b817e8f71999 to your computer and use it in GitHub Desktop.
func upload(files: [URL]) async throws -> Bool {
try await withThrowingTaskGroup(of: Bool.self) { group in
let session = try SSH(host: "xxx", port:"xxx")
let sftp = try session.openSftp()
for file in files {
group.addTask {
try await self.upload(file: file, with: sftp, session: session)
}
}
var count = 0
for try await isSuccessful in group where isSuccessful {
count += 1
}
return count == files.count
}
}
@williamhqs
Copy link

@robertmryan That's already a great help for me, thank you for you time, have a good day! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment