Tweaked a couple of errors, fixed a network bugs resulting from merge

pull/991/head
Morgan Pretty 8 months ago
parent d95744ce2e
commit 7874095d21

@ -1 +1 @@
Subproject commit 9d1b1f7e87b1061b051f2fe5e729135a6fd8c299
Subproject commit d6147ef385e39d3fae64611dcf16ac1e14bab333

@ -8109,7 +8109,7 @@
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 464;
CURRENT_PROJECT_VERSION = 465;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@ -8187,7 +8187,7 @@
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 464;
CURRENT_PROJECT_VERSION = 465;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;

@ -193,7 +193,7 @@ public extension LibSession {
guard
nodesSize > 0,
let cSwarm: UnsafeMutablePointer<network_service_node> = nodesPtr
else { return CallbackWrapper<Output>.run(ctx, .failure(SnodeAPIError.unableToRetrieveSwarm)) }
else { return CallbackWrapper<Output>.run(ctx, .failure(SnodeAPIError.ranOutOfRandomSnodes(nil))) }
var nodes: Set<Snode> = []
(0..<nodesSize).forEach { index in nodes.insert(Snode(cSwarm[index])) }
@ -202,9 +202,9 @@ public extension LibSession {
}
.tryMap { result in
switch result {
case .failure(let error): throw error
case .failure(let error): throw SnodeAPIError.ranOutOfRandomSnodes(error)
case .success(let nodes):
guard nodes.count >= count else { throw SnodeAPIError.unableToRetrieveSwarm }
guard nodes.count >= count else { throw SnodeAPIError.ranOutOfRandomSnodes(nil) }
return nodes
}
@ -401,6 +401,10 @@ public extension LibSession {
Log.warn("[LibSession] Attempted to access suspended network.")
return Fail(error: NetworkError.suspended).eraseToAnyPublisher()
}
guard Singleton.hasAppContext && (Singleton.appContext.isMainApp || Singleton.appContext.isShareExtension) else {
Log.warn("[LibSession] Attempted to create network in invalid extension.")
return Fail(error: NetworkError.suspended).eraseToAnyPublisher()
}
guard networkCache.wrappedValue == nil else {
return Just(networkCache.wrappedValue)

@ -57,9 +57,7 @@ public enum SnodeAPIError: Error, CustomStringConvertible {
case .ranOutOfRandomSnodes(let maybeError):
switch maybeError {
case .none: return "Ran out of random snodes (SnodeAPIError.ranOutOfRandomSnodes(nil))."
case .some(let error):
let errorDesc = "\(error)".trimmingCharacters(in: CharacterSet(["."]))
return "Ran out of random snodes (SnodeAPIError.ranOutOfRandomSnodes(\(errorDesc))."
case .some(let error): return "Ran out of random snodes (SnodeAPIError.ranOutOfRandomSnodes(\(error))."
}
// ONS

Loading…
Cancel
Save