mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-11-11 07:30:28 +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:
1 parent
88f71b240d
commit
2431d5de0e
1 file changed
+3
-1
@@ -19,6 +19,7 @@
|
|||||||
#
|
#
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
@@ -123,7 +124,8 @@ class TriggerLoader:
|
|||||||
*package_path_parts, class_name = module_path.split(".")
|
*package_path_parts, class_name = module_path.split(".")
|
||||||
package_or_path = ".".join(package_path_parts)
|
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)
|
module = self._load_module_from_file(package_or_path, class_name)
|
||||||
else:
|
else:
|
||||||
module = self._load_module_from_package(package_or_path)
|
module = self._load_module_from_package(package_or_path)
|
||||||
|
|||||||
Reference in new issue
Block a user