fix: check read permission before entering a folder
This commit is contained in:
parent
51724a1aa6
commit
a144262f8c
1 changed files with 9 additions and 5 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue