mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-30 00:55:30 +02:00
set inaccessible in stat if lstat fails
This commit is contained in:
parent
4bfa8e4e96
commit
b958496a5b
@ -25,7 +25,27 @@ from pwd import getpwuid
|
||||
from grp import getgrgid
|
||||
|
||||
def get_stat(full_path, filename = '/'):
|
||||
stats = os.lstat(full_path)
|
||||
try:
|
||||
stats = os.lstat(full_path)
|
||||
except OSError:
|
||||
return {
|
||||
"filename": filename,
|
||||
"isdir": False,
|
||||
"link-target": "",
|
||||
"stat": {
|
||||
"inaccessible": True,
|
||||
"mode": 0,
|
||||
"mode-str": "?",
|
||||
"uid": 0,
|
||||
"owner": "?",
|
||||
"gid": 0,
|
||||
"group": "?",
|
||||
"size": 0,
|
||||
"atime": 0,
|
||||
"mtime": 0,
|
||||
"ctime": 0
|
||||
}
|
||||
}
|
||||
isdir = False
|
||||
try:
|
||||
isdir = S_ISDIR(os.stat(full_path).st_mode)
|
||||
@ -45,6 +65,7 @@ def get_stat(full_path, filename = '/'):
|
||||
except:
|
||||
pass
|
||||
response = {
|
||||
"inaccessible": False,
|
||||
"filename": filename,
|
||||
"isdir": isdir,
|
||||
"link-target": link_target,
|
||||
|
Loading…
x
Reference in New Issue
Block a user