From a144262f8ca762915aca635510ce3de288d3d8d8 Mon Sep 17 00:00:00 2001 From: lohhiiccc <96543753+lohhiiccc@users.noreply.github.com> Date: Thu, 2 Jul 2026 20:05:42 +0200 Subject: [PATCH] fix: check read permission before entering a folder --- src/core/Navigator.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/Navigator.py b/src/core/Navigator.py index 8d446e3..508d61c 100644 --- a/src/core/Navigator.py +++ b/src/core/Navigator.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from ..items.AItems import AItem from ..items.Folder import Folder @@ -44,24 +45,27 @@ class Navigator: else: self._cursor.resete() - def _navigate_to(self, path: Path) -> None: + def _navigate_to(self, path: Path) -> bool: + if not os.access(path, os.R_OK | os.X_OK): + self._error = f"Permission denied: {path}" + return False self._history.append(path) + self._error = None self._load() self._reset_cursor() + return True def enter(self, item: AItem) -> bool: if not item.is_navigable(): return False path = item.point_to if isinstance(item, Symlink) else item.path - self._navigate_to(path) - return True + return self._navigate_to(path) def up(self) -> bool: parent = self._history[-1].parent if parent == self._history[-1]: return False - self._navigate_to(parent) - return True + return self._navigate_to(parent) def back(self) -> bool: if len(self._history) <= 1: