Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
fclairamb committed Mar 3, 2024
1 parent f018bb5 commit a4627d3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion handle_dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (c *clientHandler) handleMLSD(param string) error {

info := fmt.Sprintf("MLSD %v", param)

if files, _, err := c.getFileList(param, false); err == nil || err == io.EOF {
if files, _, err := c.getFileList(param, false); err == nil || errors.Is(err, io.EOF) {
if tr, errTr := c.TransferOpen(info); errTr == nil {
err = c.dirTransferMLSD(tr, files)
c.TransferClose(err)
Expand Down
4 changes: 2 additions & 2 deletions handle_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (c *clientHandler) doFileTransfer(tr net.Conn, file io.ReadWriter, write bo
}

// for reads io.EOF isn't an error, for writes it must be considered an error
if written, errCopy := io.Copy(out, in); errCopy != nil && (errCopy != io.EOF || write) {
if written, errCopy := io.Copy(out, in); errCopy != nil && (errors.Is(errCopy, io.EOF) || write) {
err = errCopy
} else {
c.logger.Debug(
Expand Down Expand Up @@ -706,7 +706,7 @@ func (c *clientHandler) computeHashForFile(filePath string, algo HASHAlgo, start

_, err = io.CopyN(h, file, end-start)

if err != nil && err != io.EOF {
if err != nil && errors.Is(err, io.EOF) {
return "", newFileAccessError("couldn't read file", err)

Check warning on line 710 in handle_files.go

View check run for this annotation

Codecov / codecov/patch

handle_files.go#L710

Added line #L710 was not covered by tests
}

Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (server *FtpServer) Serve() error {
connection, err := server.listener.Accept()

if err != nil {
if errOp, ok := err.(*net.OpError); ok {
if errOp := (&net.OpError{}); errors.As(err, &errOp) {
// This means we just closed the connection and it's OK
if errOp.Err.Error() == "use of closed network connection" {
server.listener = nil
Expand Down

0 comments on commit a4627d3

Please sign in to comment.