Fix crash
This commit is contained in:
parent
7ca3b73fd8
commit
9ebb448b5f
|
@ -349,11 +349,11 @@ public enum OnionRequestAPI {
|
|||
|
||||
public static func sendOnionRequest(with payload: JSON, to destination: Destination, isJSONRequired: Bool = true) -> Promise<JSON> {
|
||||
let (promise, seal) = Promise<JSON>.pending()
|
||||
var guardSnode: Snode!
|
||||
var guardSnode: Snode?
|
||||
Threading.workQueue.async { // Avoid race conditions on `guardSnodes` and `paths`
|
||||
buildOnion(around: payload, targetedAt: destination).done2 { intermediate in
|
||||
guardSnode = intermediate.guardSnode
|
||||
let url = "\(guardSnode.address):\(guardSnode.port)/onion_req/v2"
|
||||
let url = "\(guardSnode!.address):\(guardSnode!.port)/onion_req/v2"
|
||||
let finalEncryptionResult = intermediate.finalEncryptionResult
|
||||
let onion = finalEncryptionResult.ciphertext
|
||||
if case Destination.server = destination, Double(onion.count) > 0.75 * Double(maxFileSize) {
|
||||
|
|
|
@ -970,6 +970,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
|
|||
result = [self profileNameForRecipientWithID:recipientID transaction:transaction];
|
||||
}];
|
||||
|
||||
if (recipientID.length > 8) {
|
||||
NSString *shortID = [recipientID substringWithRange:NSMakeRange(recipientID.length - 8, 8)];
|
||||
NSString *suffix = [NSString stringWithFormat:@" (...%@)", shortID];
|
||||
if ([result hasSuffix:suffix]) {
|
||||
|
@ -977,6 +978,9 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
|
|||
} else {
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
return result; // Should never occur
|
||||
}
|
||||
} else {
|
||||
return recipientID;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue