Skip to content
Snippets Groups Projects
Commit 281cb14d authored by Anon's avatar Anon
Browse files

py/fil3s: handle os.listdir() errors

parent 01d4547b
No related branches found
No related tags found
1 merge request!105py: Create file manager app
...@@ -117,11 +117,18 @@ class Browser(ActionView): ...@@ -117,11 +117,18 @@ class Browser(ActionView):
def _select(self) -> None: def _select(self) -> None:
name = self.dir_entries[self.current_pos][0] name = self.dir_entries[self.current_pos][0]
if self._is_dir(self.path + name): old_path = self.path
self._change_path(self.path + name + "/") new_path = self.path + name
else: try:
self.update_path(self.path + name) if self._is_dir(new_path):
self.navigate("reader") self._change_path(new_path + "/")
else:
self.update_path(self.path + name)
self.navigate("reader")
except Exception as e:
# TODO: Create error view
print(f"Failed to open {new_path}: {e}")
self._change_path(old_path)
def _up(self) -> None: def _up(self) -> None:
if not self.up_enabled or len(self.path) <= 1: if not self.up_enabled or len(self.path) <= 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment