From c2cccf0173dc856c1ae9edca66834062dee986b6 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Tue, 19 Jan 2021 16:39:15 +0100 Subject: [PATCH] Fix conflict in treeview for top directories Happened if a filename has the same name of a top directory. It will cause a collision in the string to identify the entry into the cache. --- data/plugins/treeview.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua index 71ea9869..08ec94ad 100644 --- a/data/plugins/treeview.lua +++ b/data/plugins/treeview.lua @@ -35,7 +35,11 @@ function TreeView:get_cached(item, dirname) dir_cache = {} self.cache[dirname] = dir_cache end - local t = dir_cache[item.filename] + -- to discriminate top directories from regular files or subdirectories + -- we add ':' at the end of the top directories' filename. it will be + -- used only to identify the entry into the cache. + local cache_name = item.filename .. (item.topdir and ":" or "") + local t = dir_cache[cache_name] if not t then t = {} local basename = common.basename(item.filename) @@ -51,7 +55,7 @@ function TreeView:get_cached(item, dirname) end t.name = basename t.type = item.type - dir_cache[item.filename] = t + dir_cache[cache_name] = t end return t end