Fix build warnings; fix crash around url session errors.
This commit is contained in:
parent
b890fdeed8
commit
34b6da7b2f
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -42,8 +42,12 @@ class AdvancedPinSettingsTableViewController: OWSTableViewController {
|
||||
}
|
||||
self.navigationController?.pushViewController(vc, animated: true)
|
||||
} else {
|
||||
PinSetupViewController.disablePinWithConfirmation(fromViewController: self).done { [weak self] _ in
|
||||
firstly(on: .main) {
|
||||
PinSetupViewController.disablePinWithConfirmation(fromViewController: self)
|
||||
}.done { [weak self] _ in
|
||||
self?.updateTableContents()
|
||||
}.catch { error in
|
||||
owsFailDebug("Error: \(error)")
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -1209,7 +1209,7 @@ class StorageServiceOperation: OWSOperation {
|
||||
private func cleanUpUnknownIdentifiers(transaction: SDSAnyWriteTransaction) {
|
||||
// We may have learned of new record types; if so we should
|
||||
// cull them from the unknownIdentifiersTypeMap on launch.
|
||||
var knownTypes: [StorageServiceProtoManifestRecordKeyType] = [
|
||||
let knownTypes: [StorageServiceProtoManifestRecordKeyType] = [
|
||||
.contact,
|
||||
.groupv1,
|
||||
.groupv2,
|
||||
|
||||
@ -29,7 +29,7 @@ public extension UIEdgeInsets {
|
||||
return plus(-inset)
|
||||
}
|
||||
|
||||
public var asSize: CGSize {
|
||||
var asSize: CGSize {
|
||||
CGSize(width: left + right,
|
||||
height: top + bottom)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -101,7 +101,7 @@ public class MessageFetcherJob: NSObject {
|
||||
completionQueue.async {
|
||||
self.operationQueue.waitUntilAllOperationsAreFinished()
|
||||
|
||||
_ = self.serialQueue.sync {
|
||||
self.serialQueue.sync {
|
||||
self.activeFetchCycles.remove(fetchCycle.uuid)
|
||||
self.completedFetchCyclesCounter += 1
|
||||
}
|
||||
|
||||
@ -963,13 +963,12 @@ private class UploadTaskState: TaskState {
|
||||
// i.e. OWSURLSession --(session)--> URLSession --(delegate)--> URLSessionDelegateBox
|
||||
// x-----(weakDelegate)-----|
|
||||
//
|
||||
private typealias BoxedType = (URLSessionDelegate & URLSessionTaskDelegate & URLSessionDownloadDelegate)
|
||||
private class URLSessionDelegateBox: NSObject, BoxedType {
|
||||
private class URLSessionDelegateBox: NSObject {
|
||||
|
||||
private weak var weakDelegate: BoxedType?
|
||||
private var strongReference: BoxedType?
|
||||
private weak var weakDelegate: OWSURLSession?
|
||||
private var strongReference: OWSURLSession?
|
||||
|
||||
init(delegate: BoxedType) {
|
||||
init(delegate: OWSURLSession) {
|
||||
self.weakDelegate = delegate
|
||||
}
|
||||
|
||||
@ -981,6 +980,11 @@ private class URLSessionDelegateBox: NSObject, BoxedType {
|
||||
strongReference = newValue ? weakDelegate : nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
extension URLSessionDelegateBox: URLSessionDelegate, URLSessionTaskDelegate, URLSessionDownloadDelegate {
|
||||
|
||||
// Any of the optional methods will be forwarded using objc selector forwarding
|
||||
// If all goes according to plan, weakDelegate will only go nil once everything is being dealloced
|
||||
@ -989,16 +993,75 @@ private class URLSessionDelegateBox: NSObject, BoxedType {
|
||||
weakDelegate?.urlSession(session, downloadTask: downloadTask, didFinishDownloadingTo: location)
|
||||
}
|
||||
|
||||
override func responds(to aSelector: Selector!) -> Bool {
|
||||
return super.responds(to: aSelector) || (weakDelegate?.responds(to: aSelector) == true)
|
||||
func urlSession(_ session: URLSession,
|
||||
downloadTask: URLSessionDownloadTask,
|
||||
didWriteData bytesWritten: Int64,
|
||||
totalBytesWritten: Int64,
|
||||
totalBytesExpectedToWrite: Int64) {
|
||||
weakDelegate?.urlSession(session,
|
||||
downloadTask: downloadTask,
|
||||
didWriteData: bytesWritten,
|
||||
totalBytesWritten: totalBytesWritten,
|
||||
totalBytesExpectedToWrite: totalBytesExpectedToWrite)
|
||||
}
|
||||
|
||||
override func forwardingTarget(for aSelector: Selector!) -> Any? {
|
||||
if weakDelegate?.responds(to: aSelector) == true {
|
||||
return weakDelegate
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
func urlSession(_ session: URLSession,
|
||||
downloadTask: URLSessionDownloadTask,
|
||||
didResumeAtOffset fileOffset: Int64,
|
||||
expectedTotalBytes: Int64) {
|
||||
weakDelegate?.urlSession(session,
|
||||
downloadTask: downloadTask,
|
||||
didResumeAtOffset: fileOffset,
|
||||
expectedTotalBytes: expectedTotalBytes)
|
||||
}
|
||||
|
||||
public typealias URLAuthenticationChallengeCompletion = OWSURLSession.URLAuthenticationChallengeCompletion
|
||||
|
||||
func urlSession(_ session: URLSession,
|
||||
task: URLSessionTask,
|
||||
didReceive challenge: URLAuthenticationChallenge,
|
||||
completionHandler: @escaping URLAuthenticationChallengeCompletion) {
|
||||
weakDelegate?.urlSession(session,
|
||||
task: task,
|
||||
didReceive: challenge,
|
||||
completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession,
|
||||
task: URLSessionTask,
|
||||
didSendBodyData bytesSent: Int64,
|
||||
totalBytesSent: Int64,
|
||||
totalBytesExpectedToSend: Int64) {
|
||||
weakDelegate?.urlSession(session,
|
||||
task: task,
|
||||
didSendBodyData: bytesSent,
|
||||
totalBytesSent: totalBytesSent,
|
||||
totalBytesExpectedToSend: totalBytesExpectedToSend)
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
|
||||
weakDelegate?.urlSession(session,
|
||||
task: task,
|
||||
didCompleteWithError: error)
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession,
|
||||
didReceive challenge: URLAuthenticationChallenge,
|
||||
completionHandler: @escaping URLAuthenticationChallengeCompletion) {
|
||||
weakDelegate?.urlSession(session,
|
||||
didReceive: challenge,
|
||||
completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
func urlSession(_ session: URLSession,
|
||||
task: URLSessionTask,
|
||||
willPerformHTTPRedirection response: HTTPURLResponse,
|
||||
newRequest: URLRequest,
|
||||
completionHandler: @escaping (URLRequest?) -> Void) {
|
||||
weakDelegate?.urlSession(session,
|
||||
task: task,
|
||||
willPerformHTTPRedirection: response,
|
||||
newRequest: newRequest,
|
||||
completionHandler: completionHandler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -1526,7 +1526,7 @@ public class SSKProtoCallMessageIceUpdate: NSObject, Codable {
|
||||
|
||||
fileprivate convenience init(_ proto: SignalServiceProtos_CallMessage.IceUpdate) throws {
|
||||
guard proto.hasID else {
|
||||
throw SSKProtoError.invalidProtobuf(description: "\(Self.logTag) missing required field: id")
|
||||
throw SSKProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: id")
|
||||
}
|
||||
let id = proto.id
|
||||
|
||||
|
||||
@ -376,7 +376,7 @@ private class ModelReadCache<KeyType: AnyObject & Hashable, ValueType: BaseModel
|
||||
// Once the write transaction has completed, it is safe
|
||||
// to use the cache for this key again for .read caches.
|
||||
transaction.addSyncCompletion {
|
||||
_ = self.performSync {
|
||||
self.performSync {
|
||||
self.removeExclusion(for: cacheKey)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -88,7 +88,7 @@ public struct StorageService {
|
||||
}
|
||||
|
||||
public func buildRecord() throws -> StorageServiceProtoManifestRecordKey {
|
||||
var builder = StorageServiceProtoManifestRecordKey.builder(data: data, type: type)
|
||||
let builder = StorageServiceProtoManifestRecordKey.builder(data: data, type: type)
|
||||
return try builder.build()
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user