ensure_exists now accepts only argument

This commit is contained in:
2026-02-13 21:45:14 +02:00
parent 2a137b42f5
commit 231d3b47da
3 changed files with 6 additions and 12 deletions

View File

@@ -79,7 +79,7 @@ def move_packages(repository_paths: RepositoryPaths, pacman: Pacman) -> None:
artifacts.append(signature)
for source in artifacts:
target = repository_paths.ensure_exists(repository_paths.archive_for, package.base) / source.name
target = repository_paths.ensure_exists(repository_paths.archive_for(package.base)) / source.name
# move package to the archive directory
atomic_move(source, target)
# create symlink to the archive

View File

@@ -171,7 +171,7 @@ class Executor(PackageInfo, Cleaner):
files = self.sign.process_sign_package(full_path, packager_key)
for src in files:
dst = self.paths.ensure_exists(self.paths.archive_for, package_base) / src.name
dst = self.paths.ensure_exists(self.paths.archive_for(package_base)) / src.name
atomic_move(src, dst) # move package to archive directory
if not (symlink := self.paths.repository / dst.name).exists():
symlink_relative(symlink, dst) # create link to archive

View File

@@ -21,7 +21,7 @@ import contextlib
import os
import shutil
from collections.abc import Callable, Iterator
from collections.abc import Iterator
from dataclasses import dataclass, field
from functools import cached_property
from pathlib import Path
@@ -246,15 +246,12 @@ class RepositoryPaths(LazyLogging):
"""
return self.cache / package_base
def ensure_exists(self, directory: Callable[Params, Path] | Path, *args: Params.args,
**kwargs: Params.kwargs) -> Path:
def ensure_exists(self, directory: Path) -> Path:
"""
get path based on ``directory`` callable provided and ensure it exists
Args:
directory(Callable[Params, Path] | Path): either directory extractor or path to directory to check
args(Params.args): positional arguments for directory call
kwargs(Params.kwargs): keyword arguments for directory call
directory(Path): path to directory to check
Returns:
Path: original path based on extractor provided. Directory will always exist
@@ -262,11 +259,8 @@ class RepositoryPaths(LazyLogging):
Examples:
This method calls directory accessor and then checks if there is a directory and - otherwise - creates it::
>>> paths.ensure_exists(paths.archive_for, package_base)
>>> paths.ensure_exists(paths.archive_for(package_base))
"""
if callable(directory):
directory = directory(*args, **kwargs)
if not directory.is_dir():
with self.preserve_owner():
directory.mkdir(mode=0o755, parents=True)