Merge pull request #745 from harshavardhana/pr_out_delimit_fs_output_similar_to_s3_no_special_handling_needed
This commit is contained in:
@@ -18,7 +18,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
@@ -75,17 +74,6 @@ func doList(clnt client.Client, targetURL string, recursive bool, recursivePrefi
|
||||
err = contentCh.Err
|
||||
break
|
||||
}
|
||||
contentName := contentCh.Content.Name
|
||||
if recursive {
|
||||
// this special handling is necessary since we are sending back absolute paths with in ListRecursive()
|
||||
// a user would not wish to see a URL just for recursive and not for regular List()
|
||||
//
|
||||
// To be consistent we have to filter them out
|
||||
contentName = strings.TrimPrefix(contentName,
|
||||
strings.TrimSuffix(targetURL, string(filepath.Separator))+string(filepath.Separator))
|
||||
contentName = filepath.Join(recursivePrefix, contentName)
|
||||
}
|
||||
contentCh.Content.Name = contentName
|
||||
console.Println(parseContent(contentCh.Content))
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
+12
-1
@@ -260,6 +260,17 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *fsClient) delimiter(fp string) string {
|
||||
var stripPrefix string
|
||||
if strings.LastIndex(f.path, string(filepath.Separator)) == 0 {
|
||||
stripPrefix = string(filepath.Separator)
|
||||
}
|
||||
if strings.LastIndex(f.path, string(filepath.Separator)) > 0 {
|
||||
stripPrefix = f.path
|
||||
}
|
||||
return strings.TrimPrefix(fp, stripPrefix)
|
||||
}
|
||||
|
||||
func (f *fsClient) listRecursiveInRoutine(contentCh chan client.ContentOnChannel) {
|
||||
defer close(contentCh)
|
||||
visitFS := func(fp string, fi os.FileInfo, err error) error {
|
||||
@@ -287,7 +298,7 @@ func (f *fsClient) listRecursiveInRoutine(contentCh chan client.ContentOnChannel
|
||||
}
|
||||
if fi.Mode().IsRegular() || fi.Mode().IsDir() {
|
||||
content := &client.Content{
|
||||
Name: strings.TrimPrefix(fp, f.path),
|
||||
Name: f.delimiter(fp),
|
||||
Time: fi.ModTime(),
|
||||
Size: fi.Size(),
|
||||
Type: fi.Mode(),
|
||||
|
||||
Reference in New Issue
Block a user