Fix recursion into symlinks to dirs
This commit is contained in:
parent
37e9d2435b
commit
324b95f825
3 changed files with 15 additions and 5 deletions
|
|
@ -109,7 +109,12 @@ func icon_for(path string, x os.FileMode) string {
|
|||
if ans := icon_cache[path]; ans != "" {
|
||||
return ans
|
||||
}
|
||||
ans := icons.IconForFileWithMode(path, x, true)
|
||||
var ans string
|
||||
if x == fs.ModeDir|1 {
|
||||
ans = string(icons.SYMLINK_TO_DIR)
|
||||
} else {
|
||||
ans = icons.IconForFileWithMode(path, x, true)
|
||||
}
|
||||
if wcswidth.Stringwidth(ans) == 1 {
|
||||
ans += " "
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ func (fss *FileSystemScanner) worker() {
|
|||
}()
|
||||
seen_dirs := make(map[string]bool)
|
||||
dir, _ := filepath.Abs(fss.root_dir)
|
||||
root_dir := dir
|
||||
base := ""
|
||||
pos := 0
|
||||
var arena []sortable_dir_entry
|
||||
|
|
@ -210,7 +211,7 @@ func (fss *FileSystemScanner) worker() {
|
|||
seen_dirs[dir] = true
|
||||
entries, err := fss.dir_reader(dir)
|
||||
if err != nil {
|
||||
if dir == fss.root_dir {
|
||||
if dir == root_dir {
|
||||
fss.keep_going.Store(false)
|
||||
fss.mutex.Lock()
|
||||
fss.err = err
|
||||
|
|
@ -224,11 +225,12 @@ func (fss *FileSystemScanner) worker() {
|
|||
}
|
||||
arena = arena[:len(entries)]
|
||||
sortable = sortable[:len(entries)]
|
||||
bdir := dir + string(os.PathSeparator)
|
||||
for i, e := range entries {
|
||||
arena[i].name = e.Name()
|
||||
ftype := e.Type()
|
||||
if ftype&fs.ModeSymlink != 0 {
|
||||
if st, err := e.Info(); err == nil && st.IsDir() {
|
||||
if st, err := os.Stat(bdir + arena[i].name); err == nil && st.IsDir() {
|
||||
ftype = fs.ModeDir | 1 // 1 indicates was originally a symlink
|
||||
}
|
||||
}
|
||||
|
|
@ -250,7 +252,6 @@ func (fss *FileSystemScanner) worker() {
|
|||
copy(ns, fss.results)
|
||||
}
|
||||
new_items := ns[len(ns):new_sz]
|
||||
bdir := dir + string(os.PathSeparator)
|
||||
for i, e := range sortable {
|
||||
new_items[i].ftype = e.ftype
|
||||
new_items[i].abspath = bdir + e.name
|
||||
|
|
|
|||
|
|
@ -139,7 +139,8 @@ const (
|
|||
SQLITE rune = 0xe7c4 //
|
||||
SUBLIME rune = 0xe7aa //
|
||||
SUBTITLE rune = 0xf0a16 //
|
||||
SYMLINK rune = 0xf481
|
||||
SYMLINK rune = 0xf481 //
|
||||
SYMLINK_TO_DIR rune = 0xf482 //
|
||||
TERRAFORM rune = 0xf1062 //
|
||||
TEXT rune = 0xf15c //
|
||||
TMUX rune = 0xebc8 //
|
||||
|
|
@ -1109,6 +1110,9 @@ func IconForFileWithMode(path string, mode fs.FileMode, follow_symlinks bool) st
|
|||
if follow_symlinks {
|
||||
if dest, err := os.Readlink(path); err == nil {
|
||||
if st, err := os.Stat(dest); err == nil {
|
||||
if st.IsDir() {
|
||||
return string(SYMLINK_TO_DIR)
|
||||
}
|
||||
return IconForFileWithMode(dest, st.Mode(), follow_symlinks)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue