Skip to content

Commit

Permalink
fix some error checks (#457) by @drakkan
Browse files Browse the repository at this point in the history
The following commit reversed the logic of some error checks

8cdfc8d
  • Loading branch information
drakkan committed Jun 2, 2024
1 parent bfb6dd6 commit d2b3c25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()
Expand Down
4 changes: 2 additions & 2 deletions handle_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit d2b3c25

Please sign in to comment.