Skip to content

Commit

Permalink
fixes #187 - Update to latest jlaffaye/ftp library to fix issue where… (
Browse files Browse the repository at this point in the history
#188)

* fixes #187 - Update to latest jlaffaye/ftp library to fix issue where FTPS connections were failing due to a bug in the library. Also updated dataconn to continue even if it fails to MakeDir.

* remove unncessary module used in testing

* add test for error handling in dataconn openWriteConnection
  • Loading branch information
funkyshu authored May 30, 2024
1 parent 71131bb commit 7017a37
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 53 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]

## [6.14.2] - 2024-05-30
### Fixed
- Fixed #187 - Update to latest jlaffaye/ftp library to fix issue where FTPS connections were failing due to a bug in the library. Also updated dataconn to continue even if it fails to MakeDir.


## [6.14.1] - 2024-05-28
### Fixed
- Fixed #185 - location.Exists was checking if a list entry was a directory but it was was only checking the first entry.
Expand Down
7 changes: 6 additions & 1 deletion backend/ftp/dataconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"io"
"net/textproto"
"time"

_ftp "github.com/jlaffaye/ftp"
Expand Down Expand Up @@ -193,7 +194,11 @@ func openWriteConnection(client types.Client, f *File) (types.DataConn, error) {
if !found {
err := client.MakeDir(f.Location().Path())
if err != nil {
return nil, err
var e *textproto.Error
if !(errors.As(err, &e) && e.Code == _ftp.StatusFileUnavailable) {
// Return if the error is not because the directory already exists
return nil, err
}
}
}
pr, pw := io.Pipe()
Expand Down
18 changes: 18 additions & 0 deletions backend/ftp/dataconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ func (s *dataConnSuite) TestGetDataConn_WriteLocationNotExists() {
time.Sleep(50 * time.Millisecond)
}

func (s *dataConnSuite) TestGetDataConn_WriteLocationNotExistsFails() {
someerr := errors.New("some error")
// dataconn is nil - opebrewn for write - location doesnt exist - success
s.client.EXPECT().
List("/").
Return(nil, errors.New("550")).
Once()
s.client.EXPECT().
MakeDir(s.ftpFile.Location().Path()).
Return(someerr).
Once()
_, err := getDataConn(context.Background(), utils.Authority{}, s.ftpFile.fileSystem, s.ftpFile, types.OpenWrite)
s.ErrorIs(err, someerr, "error expected")

// brief sleep to ensure goroutines running StorFrom can all complete
time.Sleep(50 * time.Millisecond)
}

func (s *dataConnSuite) TestGetDataConn_errorWriting() {
entries := []*_ftp.Entry{{
Name: "some",
Expand Down
34 changes: 18 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ require (
github.com/Azure/azure-pipeline-go v0.2.3
github.com/Azure/azure-storage-blob-go v0.15.0
github.com/Azure/go-autorest/autorest v0.11.29
github.com/Azure/go-autorest/autorest/adal v0.9.23
github.com/aws/aws-sdk-go v1.53.3
github.com/Azure/go-autorest/autorest/adal v0.9.24
github.com/aws/aws-sdk-go v1.53.13
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349
github.com/fatih/color v1.17.0
github.com/fsouza/fake-gcs-server v1.49.0
github.com/jlaffaye/ftp v0.2.0
github.com/jlaffaye/ftp v0.2.1-0.20240214224549-4edb16bfcd0f
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/sftp v1.13.6
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.23.0
golang.org/x/net v0.25.0
google.golang.org/api v0.180.0
google.golang.org/api v0.182.0
)

require (
cloud.google.com/go v0.113.0 // indirect
cloud.google.com/go/auth v0.4.1 // indirect
cloud.google.com/go v0.114.0 // indirect
cloud.google.com/go/auth v0.5.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.8 // indirect
Expand All @@ -36,7 +36,7 @@ require (
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -52,26 +52,28 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-ieproxy v0.0.11 // indirect
github.com/mattn/go-ieproxy v0.0.12 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pkg/xattr v0.4.9 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect
go.opentelemetry.io/otel v1.26.0 // indirect
go.opentelemetry.io/otel/metric v1.26.0 // indirect
go.opentelemetry.io/otel/trace v1.26.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/genproto v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 7017a37

Please sign in to comment.