mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-02-04 20:39:47 +00:00
fix: handle permissionerror during walking over tree
Previously it tried to look into 700 directories (e.g. .gnupg) which breaks running as non-ahriman user
This commit is contained in:
@@ -11,7 +11,7 @@ from unittest.mock import call as MockCall
|
||||
from ahriman.core.exceptions import BuildError, CalledProcessError, OptionError, UnsafeRunError
|
||||
from ahriman.core.utils import check_output, check_user, dataclass_view, enum_values, extract_user, filter_json, \
|
||||
full_version, minmax, package_like, parse_version, partition, pretty_datetime, pretty_interval, pretty_size, \
|
||||
safe_filename, srcinfo_property, srcinfo_property_list, trim_package, utcnow, walk
|
||||
safe_filename, safe_iterdir, srcinfo_property, srcinfo_property_list, trim_package, utcnow, walk
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.package_source import PackageSource
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
@@ -426,6 +426,14 @@ def test_safe_filename() -> None:
|
||||
assert safe_filename("tolua++-1.0.93-4-x86_64.pkg.tar.zst") == "tolua---1.0.93-4-x86_64.pkg.tar.zst"
|
||||
|
||||
|
||||
def test_safe_iterdir(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress PermissionError
|
||||
"""
|
||||
iterdir_mock = mocker.patch("pathlib.Path.iterdir", side_effect=PermissionError)
|
||||
assert list(safe_iterdir(Path("root"))) == []
|
||||
|
||||
|
||||
def test_srcinfo_property() -> None:
|
||||
"""
|
||||
must correctly extract properties
|
||||
|
||||
Reference in New Issue
Block a user