mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 07:17:17 +00:00
fix bug with checking file
The bug appear when the file exists or doesn't, but we don't have permissions to read it. This one must be treated as missed permission
This commit is contained in:
parent
89a2d8e298
commit
709db6a5ed
@ -19,6 +19,7 @@
|
||||
#
|
||||
import importlib
|
||||
import logging
|
||||
import os
|
||||
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
@ -123,7 +124,8 @@ class TriggerLoader:
|
||||
*package_path_parts, class_name = module_path.split(".")
|
||||
package_or_path = ".".join(package_path_parts)
|
||||
|
||||
if Path(package_or_path).is_file():
|
||||
# it works for both missing permission and file does not exist
|
||||
if os.access(Path(package_or_path), os.R_OK):
|
||||
module = self._load_module_from_file(package_or_path, class_name)
|
||||
else:
|
||||
module = self._load_module_from_package(package_or_path)
|
||||
|
Loading…
Reference in New Issue
Block a user