From d2b3c256940c30356003a44d4a47b406402a49a1 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sun, 2 Jun 2024 21:37:53 +0200 Subject: [PATCH] fix some error checks (#457) by @drakkan The following commit reversed the logic of some error checks https://github.com/fclairamb/ftpserverlib/commit/8cdfc8db70344a007e3f6ec1d54656cf25b2b6ec --- driver_test.go | 2 +- handle_files.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/driver_test.go b/driver_test.go index 1e11572d..b9a7ccb1 100644 --- a/driver_test.go +++ b/driver_test.go @@ -105,7 +105,7 @@ func NewTestServerWithDriverAndLogger(t *testing.T, driver MainDriver, logger lo }) go func() { - if err := server.Serve(); err != nil && errors.Is(err, io.EOF) { + if err := server.Serve(); err != nil && !errors.Is(err, io.EOF) { server.Logger.Error("problem serving", "err", err) } }() diff --git a/handle_files.go b/handle_files.go index a7a403a1..0b41ba12 100644 --- a/handle_files.go +++ b/handle_files.go @@ -146,7 +146,7 @@ func (c *clientHandler) doFileTransfer(transferConn net.Conn, file io.ReadWriter } // for reads io.EOF isn't an error, for writes it must be considered an error - if written, errCopy := io.Copy(writer, reader); errCopy != nil && (errors.Is(errCopy, io.EOF) || write) { + if written, errCopy := io.Copy(writer, reader); errCopy != nil && (!errors.Is(errCopy, io.EOF) || write) { err = errCopy } else { c.logger.Debug( @@ -704,7 +704,7 @@ func (c *clientHandler) computeHashForFile(filePath string, algo HASHAlgo, start _, err = io.CopyN(chosenHashAlgo, file, end-start) - if err != nil && errors.Is(err, io.EOF) { + if err != nil && !errors.Is(err, io.EOF) { return "", newFileAccessError("couldn't read file", err) }