mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 07:55:10 +02:00
Fix recursion into symlinks to dirs
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user