@@ -62,15 +62,23 @@ local function link_new(cwd, name)
62
62
--- I dont know if this is needed, because in my understanding, there isnt hard links in windows, but just to be sure i changed it.
63
63
local absolute_path = utils .path_join ({ cwd , name })
64
64
local link_to = luv .fs_realpath (absolute_path )
65
+ local stat = luv .fs_stat (absolute_path )
65
66
local open , entries
66
67
if (link_to ~= nil ) and luv .fs_stat (link_to ).type == ' directory' then
67
68
open = false
68
69
entries = {}
69
70
end
71
+
72
+ local last_modified = 0
73
+ if stat ~= nil then
74
+ last_modified = stat .mtime .sec
75
+ end
76
+
70
77
return {
71
78
name = name ,
72
79
absolute_path = absolute_path ,
73
80
link_to = link_to ,
81
+ last_modified = last_modified ,
74
82
open = open ,
75
83
group_next = nil , -- If node is grouped, this points to the next child dir/link node
76
84
entries = entries ,
@@ -198,6 +206,16 @@ function M.refresh_entries(entries, cwd, parent_node)
198
206
199
207
local idx = 1
200
208
for _ , name in ipairs (cached_entries ) do
209
+ local node = named_entries [name ]
210
+ if node and node .link_to then
211
+ -- If the link has been modified: remove it in case the link target has changed.
212
+ local stat = luv .fs_stat (node .absolute_path )
213
+ if stat and node .last_modified ~= stat .mtime .sec then
214
+ new_entries [name ] = nil
215
+ named_entries [name ] = nil
216
+ end
217
+ end
218
+
201
219
if not new_entries [name ] then
202
220
table.remove (entries , idx )
203
221
else
0 commit comments