Commit Graph

17 Commits

Author SHA1 Message Date
Nick Craig-Wood
36e873b513
Fix GetEntry / MLST for some servers - Fixes #321 (#322)
Some servers seem to send a blank line at the end of an MLST response.

    MLST Download
    250-
    Size=53248;Modify=20230327134339.000;Type=dir; Download

    250 Requested file action okay, completed.

Before this change this would cause the GetEntry method to return this
error.

    unsupported LIST line

This patch ignores blank lines in the MLST response.
2023-05-12 22:29:37 -04:00
Thomas Hallgren
0aeb8660a7
Add MLST command in the form of a Get method (#269)
* Add MLST command in the form of a Get method

The `LIST` and `MLSD` commands are inefficient when the objective
is to retrieve one single `Entry` for a known path, because the only way
to get such an entry is to list the parent directory using a data
connection. The `MLST` fixes this by allowing one single `Entry` to be
returned using the control connection.

The name `Get` was chosen because it is often used in conjunction with
`List` as a mean to get one single entry.

Signed-off-by: Thomas Hallgren <thomas@datawire.io>

* Changes in response to code review:

- Rename `Get` to `GetEntry` (because it returns an `*Entry`)
- Add test-case for multiline response on the control connection
- Fix issues with parsing the multiline response.

Signed-off-by: Thomas Hallgren <thomas@datawire.io>

* Add sample output from MLST to GetEntry comment.

Signed-off-by: Thomas Hallgren <thomas@datawire.io>

* Changes in response to code review:

- Remove unused `time.Time` argument
- Add struct labels to make `govet` happy

Signed-off-by: Thomas Hallgren <thomas@datawire.io>

* Remove time arg when calling parseNextRFC3659ListLine

Signed-off-by: Thomas Hallgren <thomas@datawire.io>

Signed-off-by: Thomas Hallgren <thomas@datawire.io>
2022-08-21 17:25:29 -04:00
Julien Laffaye
45482d097e
Use assert package to simplify tests 2022-08-17 19:24:40 -04:00
Julien Laffaye
d2c44e311e Restore previous behavior for List
Fixes #251
2022-03-10 15:20:11 -05:00
Julien Laffaye
30e028f001 Check errors in tests/mocks 2022-03-08 18:35:30 -05:00
Ivan Andreev
90b220bedb Add time commands, related options, state getters and unit tests 2021-10-30 00:10:15 +03:00
Ivan Andreev
24897db640 Trim trailing whitespace from list commands
Listing a current directory (when the path argument is empty)
would send the command "LIST " with trailing whitespace to FTP
resulting in 500 errors with Solaris FTP server.
This patch fixes that.
2021-02-14 19:48:19 +03:00
Julien Laffaye
0de5c29d45 Fix issues reported by staticcheck 2020-10-21 22:10:46 +02:00
Mathias Fredriksson
420cf7bbfd
Fix tests 2020-10-20 21:16:41 +03:00
CrazyMax
696d865fa3
Opt-out 2020-07-28 21:13:33 +02:00
CrazyMax
83f3ade61d
Fix ftpMock 2020-05-05 13:34:35 +02:00
CrazyMax
0a6572881e
Udpate ftpMock 2020-05-05 13:22:37 +02:00
Florian Goetghebeur
827e50c0bd Add support for append (APPE) command 2020-03-10 11:43:17 +01:00
Florian Goetghebeur
adfb8ed9f3 Actually store file content in mock 2020-03-10 11:41:46 +01:00
Julien Laffaye
e6de3d35bf Replace DialWithOptions with Dial
No need for a dedicated function as Dial can take no options.
2019-04-23 14:04:25 +02:00
Julien Laffaye
04b1878733 Add DialWithOptions
DialWithOptions accept a variadic number of options, allowing to
introduce more options in the fure without breaking the API.
2019-04-10 20:25:16 +02:00
Julien Laffaye
55546487cf Use mock for all tests 2019-04-10 20:20:50 +02:00