Skip to content

Commit fb6ef0d

Browse files
committed
Fix swift chunked upload when using non-unique ID
1 parent 987f293 commit fb6ef0d

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

templates/swift/Sources/Client.swift.twig

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,19 @@ open class Client {
367367

368368
if idParamName != nil && params[idParamName!] as! String != "unique()" {
369369
// Make a request to check if a file already exists
370-
let map = try! await call(
371-
method: "GET",
372-
path: path + "/" + (params[idParamName!] as! String),
373-
headers: headers,
374-
params: [:],
375-
converter: { return $0 }
376-
)
377-
let chunksUploaded = map["chunksUploaded"] as! Int
378-
offset = min(size, (chunksUploaded * Client.chunkSize))
370+
do {
371+
let map = try await call(
372+
method: "GET",
373+
path: path + "/" + (params[idParamName!] as! String),
374+
headers: headers,
375+
params: [:],
376+
converter: { return $0 }
377+
)
378+
let chunksUploaded = map["chunksUploaded"] as! Int
379+
offset = min(size, (chunksUploaded * Client.chunkSize))
380+
} catch {
381+
// File does not exist yet, swallow exception
382+
}
379383
}
380384

381385
while offset < size {

0 commit comments

Comments
 (0)