Skip to content

Commit

Permalink
read fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr. Brandon Wiley committed Oct 1, 2020
1 parent 12d1095 commit 44bee7f
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions Sources/TransmissionLinux/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,23 @@ public class Connection

do
{
let _ = try self.socket.read(into: &data)
}
catch
{
return nil
}
let bytesRead = try self.socket.read(into: &data)
buffer.append(data[0..<bytesRead])

buffer.append(data)
guard size <= buffer.count else
{
return nil
}

if size > buffer.count
let result = buffer[0..<size]
buffer = buffer[size..<buffer.count]

return result
}
catch
{
return nil
}

let result = buffer[0..<size]
buffer = buffer[size..<buffer.count]

return result
}

public func write(string: String) -> Bool
Expand Down

0 comments on commit 44bee7f

Please sign in to comment.