Skip to content

Commit 7017a37

Browse files
authored
fixes #187 - Update to latest jlaffaye/ftp library to fix issue where… (#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
1 parent 71131bb commit 7017a37

File tree

5 files changed

+101
-53
lines changed

5 files changed

+101
-53
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66
## [Unreleased]
77

8+
## [6.14.2] - 2024-05-30
9+
### Fixed
10+
- 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.
11+
12+
813
## [6.14.1] - 2024-05-28
914
### Fixed
1015
- Fixed #185 - location.Exists was checking if a list entry was a directory but it was was only checking the first entry.

backend/ftp/dataconn.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"io"
7+
"net/textproto"
78
"time"
89

910
_ftp "github.com/jlaffaye/ftp"
@@ -193,7 +194,11 @@ func openWriteConnection(client types.Client, f *File) (types.DataConn, error) {
193194
if !found {
194195
err := client.MakeDir(f.Location().Path())
195196
if err != nil {
196-
return nil, err
197+
var e *textproto.Error
198+
if !(errors.As(err, &e) && e.Code == _ftp.StatusFileUnavailable) {
199+
// Return if the error is not because the directory already exists
200+
return nil, err
201+
}
197202
}
198203
}
199204
pr, pw := io.Pipe()

backend/ftp/dataconn_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,24 @@ func (s *dataConnSuite) TestGetDataConn_WriteLocationNotExists() {
113113
time.Sleep(50 * time.Millisecond)
114114
}
115115

116+
func (s *dataConnSuite) TestGetDataConn_WriteLocationNotExistsFails() {
117+
someerr := errors.New("some error")
118+
// dataconn is nil - opebrewn for write - location doesnt exist - success
119+
s.client.EXPECT().
120+
List("/").
121+
Return(nil, errors.New("550")).
122+
Once()
123+
s.client.EXPECT().
124+
MakeDir(s.ftpFile.Location().Path()).
125+
Return(someerr).
126+
Once()
127+
_, err := getDataConn(context.Background(), utils.Authority{}, s.ftpFile.fileSystem, s.ftpFile, types.OpenWrite)
128+
s.ErrorIs(err, someerr, "error expected")
129+
130+
// brief sleep to ensure goroutines running StorFrom can all complete
131+
time.Sleep(50 * time.Millisecond)
132+
}
133+
116134
func (s *dataConnSuite) TestGetDataConn_errorWriting() {
117135
entries := []*_ftp.Entry{{
118136
Name: "some",

go.mod

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ require (
77
github.com/Azure/azure-pipeline-go v0.2.3
88
github.com/Azure/azure-storage-blob-go v0.15.0
99
github.com/Azure/go-autorest/autorest v0.11.29
10-
github.com/Azure/go-autorest/autorest/adal v0.9.23
11-
github.com/aws/aws-sdk-go v1.53.3
10+
github.com/Azure/go-autorest/autorest/adal v0.9.24
11+
github.com/aws/aws-sdk-go v1.53.13
1212
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349
1313
github.com/fatih/color v1.17.0
1414
github.com/fsouza/fake-gcs-server v1.49.0
15-
github.com/jlaffaye/ftp v0.2.0
15+
github.com/jlaffaye/ftp v0.2.1-0.20240214224549-4edb16bfcd0f
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/pkg/sftp v1.13.6
1818
github.com/stretchr/testify v1.9.0
1919
golang.org/x/crypto v0.23.0
2020
golang.org/x/net v0.25.0
21-
google.golang.org/api v0.180.0
21+
google.golang.org/api v0.182.0
2222
)
2323

2424
require (
25-
cloud.google.com/go v0.113.0 // indirect
26-
cloud.google.com/go/auth v0.4.1 // indirect
25+
cloud.google.com/go v0.114.0 // indirect
26+
cloud.google.com/go/auth v0.5.0 // indirect
2727
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
2828
cloud.google.com/go/compute/metadata v0.3.0 // indirect
2929
cloud.google.com/go/iam v1.1.8 // indirect
@@ -36,7 +36,7 @@ require (
3636
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
3737
github.com/felixge/httpsnoop v1.0.4 // indirect
3838
github.com/go-errors/errors v1.5.1 // indirect
39-
github.com/go-logr/logr v1.4.1 // indirect
39+
github.com/go-logr/logr v1.4.2 // indirect
4040
github.com/go-logr/stdr v1.2.2 // indirect
4141
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
4242
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -52,26 +52,28 @@ require (
5252
github.com/hashicorp/go-multierror v1.1.1 // indirect
5353
github.com/jmespath/go-jmespath v0.4.0 // indirect
5454
github.com/kr/fs v0.1.0 // indirect
55+
github.com/kr/pretty v0.3.1 // indirect
5556
github.com/mattn/go-colorable v0.1.13 // indirect
56-
github.com/mattn/go-ieproxy v0.0.11 // indirect
57+
github.com/mattn/go-ieproxy v0.0.12 // indirect
5758
github.com/mattn/go-isatty v0.0.20 // indirect
5859
github.com/pkg/xattr v0.4.9 // indirect
5960
github.com/pmezard/go-difflib v1.0.0 // indirect
61+
github.com/rogpeppe/go-internal v1.12.0 // indirect
6062
github.com/stretchr/objx v0.5.2 // indirect
6163
go.opencensus.io v0.24.0 // indirect
62-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect
63-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect
64-
go.opentelemetry.io/otel v1.26.0 // indirect
65-
go.opentelemetry.io/otel/metric v1.26.0 // indirect
66-
go.opentelemetry.io/otel/trace v1.26.0 // indirect
64+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect
65+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
66+
go.opentelemetry.io/otel v1.27.0 // indirect
67+
go.opentelemetry.io/otel/metric v1.27.0 // indirect
68+
go.opentelemetry.io/otel/trace v1.27.0 // indirect
6769
golang.org/x/oauth2 v0.20.0 // indirect
6870
golang.org/x/sync v0.7.0 // indirect
6971
golang.org/x/sys v0.20.0 // indirect
7072
golang.org/x/text v0.15.0 // indirect
7173
golang.org/x/time v0.5.0 // indirect
72-
google.golang.org/genproto v0.0.0-20240515191416-fc5f0ca64291 // indirect
73-
google.golang.org/genproto/googleapis/api v0.0.0-20240515191416-fc5f0ca64291 // indirect
74-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
74+
google.golang.org/genproto v0.0.0-20240528184218-531527333157 // indirect
75+
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
76+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
7577
google.golang.org/grpc v1.64.0 // indirect
7678
google.golang.org/protobuf v1.34.1 // indirect
7779
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)