Skip to content

Commit

Permalink
Add missing finish. Oops.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsinclair committed Dec 31, 2019
1 parent d2cd763 commit d948f92
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Sources/Etcetera/ImageCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class ImageCache {
private let urlSession: URLSession
private let formattingTaskRegistry = TaskRegistry<ImageKey, Image?>()
private let downloadTaskRegistry = TaskRegistry<ImageKey, DownloadResult?>()
private let userImageDiskTaskRegistry = TaskRegistry<ImageKey, Void>()
private let userImageDiskTaskRegistry = TaskRegistry<ImageKey, URL>()
private let memoryCache = MemoryCache<ImageKey, Image>()
private let formattingQueue: OperationQueue
private let workQueue: OperationQueue
Expand Down Expand Up @@ -200,23 +200,24 @@ public final class ImageCache {
completion(nil)
return
}
let fileUrl = self.fileUrl(forOriginalImageWithKey: actualKey)
var saveOperation: Operation?
_ = self.userImageDiskTaskRegistry.addRequest(
taskId: actualKey,
workQueue: self.workQueue,
taskExecution: { finish in
let blockOperation = BlockOperation {
let fileUrl = self.fileUrl(forOriginalImageWithKey: actualKey)
FileManager.default.save(image, to: fileUrl)
finish(fileUrl)
}
saveOperation = blockOperation
self.formattingQueue.addOperation(blockOperation)
}, taskCancellation: {
saveOperation?.cancel()
}, taskCompletion: {
}, taskCompletion: { _ in
// no-op
}, requestCompletion: {
completion(fileUrl)
}, requestCompletion: { url in
completion(url)
}
)
}
Expand Down

0 comments on commit d948f92

Please sign in to comment.