fix(v2): support nested repository paths
This commit is contained in:
@@ -64,7 +64,13 @@ def _canonical_json(payload: dict[str, object]) -> str:
|
||||
|
||||
|
||||
def _assert_capacity(settings: Settings, root: Path) -> None:
|
||||
usage = shutil.disk_usage(root)
|
||||
capacity_root = root
|
||||
while not capacity_root.exists():
|
||||
parent = capacity_root.parent
|
||||
if parent == capacity_root:
|
||||
raise RepositoryError("repository root is unreadable")
|
||||
capacity_root = parent
|
||||
usage = shutil.disk_usage(capacity_root)
|
||||
free_percent = usage.free * 100 / usage.total
|
||||
if usage.free < settings.min_free_bytes or free_percent < settings.min_free_percent:
|
||||
raise RepositoryError("repository root does not meet minimum free capacity")
|
||||
|
||||
@@ -61,6 +61,13 @@ def test_initialization_rejects_symlinked_destination_component(tmp_path: Path)
|
||||
initialize(settings, "linked/child", "none", "none")
|
||||
|
||||
|
||||
def test_initialization_supports_not_yet_created_nested_path(tmp_path: Path) -> None:
|
||||
settings = settings_for(tmp_path)
|
||||
result = initialize(settings, "nested/main", "none", "none")
|
||||
assert result.root == settings.repository_roots[0] / "nested" / "main"
|
||||
assert (result.root / "repository.json").is_file()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("minimum", "usage"),
|
||||
[
|
||||
@@ -79,7 +86,9 @@ def test_initialization_rejects_insufficient_capacity(
|
||||
initialize(settings, "main", "none", "none")
|
||||
|
||||
|
||||
def test_initialization_emits_complete_repository_protocol_metadata(tmp_path: Path) -> None:
|
||||
def test_initialization_emits_complete_repository_protocol_metadata(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
result = initialize(settings_for(tmp_path), "main", "none", "none")
|
||||
try:
|
||||
payload = json.loads((result.root / "repository.json").read_text(encoding="utf-8"))
|
||||
|
||||
Reference in New Issue
Block a user