Skip to content

Commit

Permalink
fix some error checks
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 May 10, 2024
1 parent 5395388 commit 2fd0ae7
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 @@ -713,7 +713,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 2fd0ae7

Please sign in to comment.