Skip to content

Commit 61303c5

Browse files
author
Ruben Nine
committed
Ensuring automatic deletion of uploaded files logic is triggered in case the upload process is cancelled before starting.
1 parent dad1e2c commit 61303c5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Sources/FilestackSDK/Internal/Uploaders/MultipartUpload.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ private extension MultipartUpload {
147147

148148
// Block to run when operation completes.
149149
operation.completionBlock = {
150-
if self.options.deleteTemporaryFilesAfterUpload, let deletable = uploadable as? Deletable {
151-
deletable.delete()
152-
}
153-
154150
if let fileCompletedCount = self.progress.fileCompletedCount {
155151
self.progress.fileCompletedCount = fileCompletedCount + 1
156152
}
@@ -195,6 +191,13 @@ private extension MultipartUpload {
195191
state = .completed
196192
}
197193

194+
// Delete any deletable files if `deleteTemporaryFilesAfterUpload` option is enabled.
195+
if options.deleteTemporaryFilesAfterUpload, let deletables = (uploadables?.compactMap { $0 as? Deletable }) {
196+
for deletable in deletables {
197+
deletable.delete()
198+
}
199+
}
200+
198201
queue.async {
199202
self.completionHandler?(results)
200203
self.completionHandler = nil

0 commit comments

Comments
 (0)