Handle symlink appropriately with mc ls for filesystem

This commit is contained in:
Harshavardhana
2015-04-28 23:26:17 -07:00
parent eb8982882b
commit 5ca4280ea0
2 changed files with 8 additions and 8 deletions
+3 -3
View File
@@ -41,15 +41,15 @@ func printItem(date time.Time, v int64, name string, fileType os.FileMode) {
fmt.Printf(console.Size("%6s ", humanize.IBytes(uint64(v))))
// just making it explicit
if fileType.IsDir() {
switch fileType.IsDir() {
case true:
// if one finds a prior suffix no need to append a new one
if strings.HasSuffix(name, "/") {
fmt.Println(console.Dir("%s", name))
} else {
fmt.Println(console.Dir("%s/", name))
}
}
if fileType.IsRegular() {
default:
fmt.Println(console.File("%s", name))
}
}
+5 -5
View File
@@ -47,7 +47,7 @@ func New(path string) client.Client {
// fsStat - wrapper function to get file stat
func (f *fsClient) fsStat() (os.FileInfo, error) {
st, err := os.Stat(filepath.Clean(f.path))
st, err := os.Lstat(filepath.Clean(f.path))
if os.IsNotExist(err) {
return nil, iodine.New(NotFound{path: f.path}, nil)
}
@@ -139,7 +139,7 @@ func (f *fsClient) list(itemCh chan client.ItemOnChannel) {
Err: iodine.New(err, nil),
}
}
fi, err := dir.Stat()
fi, err := os.Lstat(f.path)
if err != nil {
itemCh <- client.ItemOnChannel{
Item: nil,
@@ -147,7 +147,8 @@ func (f *fsClient) list(itemCh chan client.ItemOnChannel) {
}
}
defer dir.Close()
if fi.Mode().IsDir() {
switch fi.Mode().IsDir() {
case true:
// do not use ioutil.ReadDir(), since it tries to sort its
// output at our scale we are expecting that to slow down
// instead we take raw output and provide it back to the user
@@ -172,8 +173,7 @@ func (f *fsClient) list(itemCh chan client.ItemOnChannel) {
Err: nil,
}
}
}
if fi.Mode().IsRegular() {
default:
item := &client.Item{
Name: dir.Name(),
Time: fi.ModTime(),