Link preview temp files.

This commit is contained in:
Matthew Chen 2019-01-17 17:06:00 -05:00
parent 186e4e14d2
commit f73f100717

View file

@ -31,6 +31,15 @@ public class OWSLinkPreviewDraft: NSObject {
super.init()
}
deinit {
// Eagerly clean up temp files.
if let imageFilePath = imageFilePath {
DispatchQueue.main.async {
OWSFileSystem.deleteFile(imageFilePath)
}
}
}
fileprivate func isValid() -> Bool {
var hasTitle = false
if let titleValue = title {
@ -462,11 +471,12 @@ public class OWSLinkPreview: MTLModel {
Logger.verbose("url: \(url)")
guard let sessionManager: AFHTTPSessionManager = ContentProxy.sessionManager(baseUrl: nil) else {
owsFailDebug("Couldn't create session manager.")
completion(nil)
return
}
let sessionConfiguration = ContentProxy.sessionConfiguration()
// Don't use any caching.
sessionConfiguration.requestCachePolicy = .reloadIgnoringLocalCacheData
sessionConfiguration.urlCache = nil
let sessionManager = AFHTTPSessionManager(baseURL: nil,
sessionConfiguration: sessionConfiguration)
sessionManager.requestSerializer = AFHTTPRequestSerializer()
sessionManager.responseSerializer = AFHTTPResponseSerializer()