fix: disk image
Build and Publish Container / Publish Linux container (push) Successful in 4m11s

This commit is contained in:
2026-10-05 18:09:15 -04:00
parent 79e953bbe7
commit c79aad1cb9
4 changed files with 145 additions and 1 deletions
+31
View File
@@ -2,6 +2,7 @@ from __future__ import annotations
import asyncio
import logging
import shutil
import time
import uuid
from collections.abc import Callable
@@ -246,6 +247,27 @@ class RefreshService:
total_targets,
(overall_timeout_seconds or 0) / 3600,
)
if targets:
remaining_bytes = sum(
max(int(details[workshop_id].file_size or 0), 0)
for workshop_id in targets
if workshop_id in details
)
workshop_root = self.settings.workshop_content_dir.parent.parent
workshop_root.mkdir(parents=True, exist_ok=True)
free_bytes = shutil.disk_usage(workshop_root).free
required_bytes = int(remaining_bytes * 1.1)
logger.info(
"Workshop capacity check: %.2f GiB expected, %.2f GiB free",
remaining_bytes / (1024**3),
free_bytes / (1024**3),
)
if required_bytes and free_bytes < required_bytes:
raise RuntimeError(
"Insufficient Workshop volume space: "
f"{free_bytes / (1024**3):.2f} GiB free, "
f"approximately {required_bytes / (1024**3):.2f} GiB required"
)
if targets and not self.runner.available():
reason = (
f"SteamCMD was not found at '{self.settings.steamcmd_path}'. "
@@ -305,6 +327,15 @@ class RefreshService:
result.elapsed_seconds,
result.output_tail or "(no SteamCMD output)",
)
if result.has_io_failure:
recover = getattr(self.runner, "recover_io_failure", None)
moved = recover() if callable(recover) else []
if moved:
logger.warning(
"SteamCMD I/O recovery quarantined transient "
"Workshop state: %s",
", ".join(str(path) for path in moved),
)
self.database.add_download_attempt(
{
"run_id": run_id,
+54 -1
View File
@@ -95,6 +95,10 @@ class SteamCmdBatchResult:
failed_ids: set[str]
output_tail: str
@property
def has_io_failure(self) -> bool:
return "i/o operation failed" in self.output_tail.lower()
class SteamCmdRunner:
def __init__(
@@ -106,6 +110,16 @@ class SteamCmdRunner:
self.executable = executable
self.content_dir = content_dir
self.timeout_seconds = timeout_seconds
self._io_recovery_attempted = False
@property
def install_root(self) -> Path:
try:
return self.content_dir.parents[3]
except IndexError as error:
raise ValueError(
f"Invalid SteamCMD Workshop content path: {self.content_dir}"
) from error
def executable_path(self) -> str | None:
configured = Path(self.executable)
@@ -130,6 +144,39 @@ class SteamCmdRunner:
"Check the container volume ownership."
) from error
def recover_io_failure(self) -> list[Path]:
"""Quarantine Steam's transient Workshop state without touching mods."""
if self._io_recovery_attempted:
return []
self._io_recovery_attempted = True
workshop_dir = self.content_dir.parent.parent
candidates = [
workshop_dir / f"appworkshop_{RIMWORLD_APP_ID}.acf",
workshop_dir / "downloads" / RIMWORLD_APP_ID,
workshop_dir / "temp" / RIMWORLD_APP_ID,
]
existing = [candidate for candidate in candidates if candidate.exists()]
if not existing:
return []
timestamp = (
datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
+ f"-{time.time_ns()}"
)
recovery_dir = workshop_dir / ".progression-recovery" / timestamp
recovery_dir.mkdir(parents=True, exist_ok=True)
moved: list[Path] = []
for candidate in existing:
label = (
candidate.name
if candidate.is_file()
else f"{candidate.parent.name}-{candidate.name}"
)
destination = recovery_dir / label
shutil.move(str(candidate), str(destination))
moved.append(destination)
return moved
def run_batch(
self,
workshop_ids: list[str],
@@ -145,7 +192,13 @@ class SteamCmdRunner:
raise ValueError(f"Invalid Workshop ids: {', '.join(invalid)}")
self.ensure_workshop_writable()
command = [executable, "+login", "anonymous"]
command = [
executable,
"+force_install_dir",
str(self.install_root),
"+login",
"anonymous",
]
for workshop_id in workshop_ids:
command.extend(
[