@@ -270,7 +270,7 @@ open class Client {
270
270
private func execute<T >(
271
271
_ request: HTTPClientRequest,
272
272
withSink bufferSink: ((ByteBuffer) -> Void)? = nil,
273
- convert : (([String: Any]) -> T)? = nil
273
+ converter : (([String: Any]) -> T)? = nil
274
274
) async throws -> T {
275
275
func complete(with response: HTTPClientResponse) async throws -> T {
276
276
switch response.status.code {
@@ -290,7 +290,7 @@ open class Client {
290
290
let data = try await response.body.collect(upTo: Int.max)
291
291
let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
292
292
293
- return convert ?(dict!) ?? dict! as! T
293
+ return converter ?(dict!) ?? dict! as! T
294
294
}
295
295
default:
296
296
var message = ""
@@ -354,26 +354,15 @@ open class Client {
354
354
355
355
if idParamName != nil && params[idParamName!] as! String != "unique()" {
356
356
// Make a request to check if a file already exists
357
- group.enter()
358
- call(
357
+ let map = try! await call(
359
358
method: "GET",
360
359
path: path + "/" + (params[idParamName!] as! String),
361
360
headers: headers,
362
361
params: [:],
363
362
converter: { return $0 }
364
- ) { response in
365
- switch response {
366
- case let .success(map):
367
- let chunksUploaded = map["chunksUploaded"] as! Int
368
- offset = min(size, (chunksUploaded * Client.chunkSize))
369
- group.leave()
370
- case let .failure(error):
371
- completion?(.failure(error))
372
- group.leave()
373
- return
374
- }
375
- }
376
- group.wait()
363
+ )
364
+ let chunksUploaded = map["chunksUploaded"] as! Int
365
+ offset = min(size, (chunksUploaded * Client.chunkSize))
377
366
}
378
367
379
368
while offset < size {
@@ -392,7 +381,7 @@ open class Client {
392
381
path: path,
393
382
headers: headers,
394
383
params: params,
395
- convert : { return $0 }
384
+ converter : { return $0 }
396
385
)
397
386
398
387
offset += Client.chunkSize
0 commit comments