Merge pull request #2660 from davep/dirtree-tweaks

This commit is contained in:
Dave Pearson
2023-05-26 15:18:58 +01:00
committed by GitHub

View File

@@ -131,6 +131,7 @@ class DirectoryTree(Tree[DirEntry]):
node: The node to add to the load queue. node: The node to add to the load queue.
""" """
assert node.data is not None assert node.data is not None
if not node.data.loaded:
node.data.loaded = True node.data.loaded = True
self._load_queue.put_nowait(node) self._load_queue.put_nowait(node)
@@ -271,6 +272,7 @@ class DirectoryTree(Tree[DirEntry]):
node: The Tree node to populate. node: The Tree node to populate.
content: The collection of `Path` objects to populate the node with. content: The collection of `Path` objects to populate the node with.
""" """
node.remove_children()
for path in content: for path in content:
node.add( node.add(
path.name, path.name,
@@ -350,7 +352,6 @@ class DirectoryTree(Tree[DirEntry]):
if dir_entry is None: if dir_entry is None:
return return
if self._safe_is_dir(dir_entry.path): if self._safe_is_dir(dir_entry.path):
if not dir_entry.loaded:
self._add_to_load_queue(event.node) self._add_to_load_queue(event.node)
else: else:
self.post_message(self.FileSelected(event.node, dir_entry.path)) self.post_message(self.FileSelected(event.node, dir_entry.path))