mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 21:41:45 +00:00
syntax fix
This commit is contained in:
parent
39fcea4a85
commit
589d9f7155
@ -231,15 +231,23 @@ final class NetworkFrameworkTcpConnectionInterface: NSObject, MTTcpConnectionInt
|
||||
self.processReadRequests()
|
||||
} else {
|
||||
connection.receive(minimumIncompleteLength: requestChunkLength, maximumLength: requestChunkLength, completion: { [weak self] data, context, isComplete, error in
|
||||
guard let self = self, let currentReadRequest = self.currentReadRequest else {
|
||||
self?.readWithBytes(data: data, isComplete: isComplete, error: error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private func readWithBytes(data: Data?, isComplete: Bool, error: Error?) {
|
||||
guard let currentReadRequest = self.currentReadRequest else {
|
||||
return
|
||||
}
|
||||
if let data = data {
|
||||
self.networkUsageManager?.addIncomingBytes(UInt(data.count), interface: self.currentInterfaceIsWifi ? MTNetworkUsageManagerInterfaceOther : MTNetworkUsageManagerInterfaceWWAN)
|
||||
|
||||
if data.count != 0 && data.count <= currentReadRequest.request.length - currentReadRequest.readyLength {
|
||||
|
||||
|
||||
currentReadRequest.data.withUnsafeMutableBytes { currentBuffer in
|
||||
guard let currentBytes = currentBuffer.assumingMemoryBound(to: UInt8.self).baseAddress else {
|
||||
guard let currentBytes = currentBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
|
||||
return
|
||||
}
|
||||
data.copyBytes(to: currentBytes.advanced(by: currentReadRequest.readyLength), count: data.count)
|
||||
@ -266,8 +274,7 @@ final class NetworkFrameworkTcpConnectionInterface: NSObject, MTTcpConnectionInt
|
||||
} else {
|
||||
self.cancelWithError(error: error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private func cancelWithError(error: Error?) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user