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>
This commit is contained in:
14
parse.go
14
parse.go
@@ -27,7 +27,11 @@ var dirTimeFormats = []string{
|
||||
}
|
||||
|
||||
// parseRFC3659ListLine parses the style of directory line defined in RFC 3659.
|
||||
func parseRFC3659ListLine(line string, now time.Time, loc *time.Location) (*Entry, error) {
|
||||
func parseRFC3659ListLine(line string, _ time.Time, loc *time.Location) (*Entry, error) {
|
||||
return parseNextRFC3659ListLine(line, loc, &Entry{})
|
||||
}
|
||||
|
||||
func parseNextRFC3659ListLine(line string, loc *time.Location, e *Entry) (*Entry, error) {
|
||||
iSemicolon := strings.Index(line, ";")
|
||||
iWhitespace := strings.Index(line, " ")
|
||||
|
||||
@@ -35,8 +39,12 @@ func parseRFC3659ListLine(line string, now time.Time, loc *time.Location) (*Entr
|
||||
return nil, errUnsupportedListLine
|
||||
}
|
||||
|
||||
e := &Entry{
|
||||
Name: line[iWhitespace+1:],
|
||||
name := line[iWhitespace+1:]
|
||||
if e.Name == "" {
|
||||
e.Name = name
|
||||
} else if e.Name != name {
|
||||
// All lines must have the same name
|
||||
return nil, errUnsupportedListLine
|
||||
}
|
||||
|
||||
for _, field := range strings.Split(line[:iWhitespace-1], ";") {
|
||||
|
||||
Reference in New Issue
Block a user