Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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]
- Replace ftp `fakeDataConn` type with mockery.

## [v7.13.0] - 2025-01-26
### Added
Expand Down
6 changes: 1 addition & 5 deletions backend/ftp/dataconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func getDataConn(ctx context.Context, a authority.Authority, fs *FileSystem, f *
fs.dataconn = nil
}

if fs.dataconn == nil || fs.resetConn {
if fs.dataconn == nil {
client, err := fs.Client(ctx, a)
if err != nil {
return nil, err
Expand Down Expand Up @@ -176,10 +176,6 @@ func getDataConn(ctx context.Context, a authority.Authority, fs *FileSystem, f *
c: client,
}
}
// ensure resetConn is false since we've opened/reopened the file
if f != nil {
fs.resetConn = false
}
}

return fs.dataconn, nil
Expand Down
5 changes: 3 additions & 2 deletions backend/ftp/dataconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,10 @@ func (s *dataConnSuite) TestGetDataConn_writeSuccess() {

func (s *dataConnSuite) TestGetDataConn_readAfterWriteError() {
// open dataconn for read after dataconn for write exists - error on dataconn.Close
fakedconn := NewFakeDataConn(types.OpenWrite)
fakedconn := mocks.NewDataConn(s.T())
fakedconn.EXPECT().Mode().Return(types.OpenWrite)
closeErr := errors.New("some close err")
fakedconn.AssertCloseErr(closeErr)
fakedconn.EXPECT().Close().Return(closeErr).Once()
s.ftpFile.location.fileSystem.dataconn = fakedconn
dc, err := getDataConn(
s.T().Context(),
Expand Down
6 changes: 3 additions & 3 deletions backend/ftp/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (f *File) Close() error {
if err != nil {
return utils.WrapCloseError(err)
}
f.location.fileSystem.resetConn = true
f.location.fileSystem.dataconn = nil
}
// no op for unopened file
f.offset = 0
Expand Down Expand Up @@ -372,7 +372,7 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
if err != nil {
return 0, utils.WrapSeekError(err)
}
f.location.fileSystem.resetConn = true
f.location.fileSystem.dataconn = nil
case 2: // offset from end of the file
sz, err := f.Size()
if err != nil {
Expand All @@ -393,7 +393,7 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
if err != nil {
return 0, utils.WrapSeekError(err)
}
f.location.fileSystem.resetConn = true
f.location.fileSystem.dataconn = nil
}
}

Expand Down
1 change: 0 additions & 1 deletion backend/ftp/fileSystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type FileSystem struct {
options Options
ftpclient types.Client
dataconn types.DataConn
resetConn bool
}

// NewFileSystem initializer for fileSystem struct.
Expand Down
Loading
Loading