From 59acb840451e1644eb00925832942defd03b02d5 Mon Sep 17 00:00:00 2001 From: captchanjack Date: Tue, 1 Feb 2022 18:21:23 +1100 Subject: [PATCH] [FEAT] Add condition for flush! --- Project.toml | 2 +- src/client.jl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index f29393c..24f0fc3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Jedis" uuid = "b89ccfe0-2c5f-46f6-b89b-da3e1c2e286f" authors = ["Jack Chan "] -version = "0.2.10" +version = "0.2.11" [deps] MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d" diff --git a/src/client.jl b/src/client.jl index 891ee65..1ce7df4 100644 --- a/src/client.jl +++ b/src/client.jl @@ -238,8 +238,10 @@ Reads and discards any bytes that remain unread in the client socket. """ function flush!(client::Client) nb = bytesavailable(client.socket) - buffer = Vector{UInt8}(undef, nb) - readbytes!(client.socket, buffer, nb) + if nb > 0 + buffer = Vector{UInt8}(undef, nb) + readbytes!(client.socket, buffer, nb) + end end """