feat: persist isolated utility export jobs
This commit is contained in:
@@ -63,6 +63,9 @@ class DownloadConfig:
|
||||
max_workers: int = 2
|
||||
process_timeout_seconds: float = 2 * 3600.0
|
||||
max_height: int = 1080
|
||||
export_directory: Path = Path("exports")
|
||||
export_max_height: int = 1080
|
||||
max_queued_exports: int = 20
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -172,6 +175,20 @@ def _optional_path(value: Any, name: str) -> Path | None:
|
||||
return Path(text)
|
||||
|
||||
|
||||
def _relative_directory(value: Any, name: str) -> Path:
|
||||
text = _text(value, name)
|
||||
assert text is not None
|
||||
path = Path(text)
|
||||
if (
|
||||
path.is_absolute()
|
||||
or not path.parts
|
||||
or any(part in {".", ".."} for part in path.parts)
|
||||
or "\\" in text
|
||||
):
|
||||
raise ConfigError(f"{name} must be a safe relative directory")
|
||||
return path
|
||||
|
||||
|
||||
def _env_value(env: Mapping[str, str], key: str, fallback: Any) -> Any:
|
||||
return env[key] if key in env else fallback
|
||||
|
||||
@@ -277,6 +294,19 @@ def load_config(
|
||||
max_workers=_integer(downloads_raw.get("max_workers", 2), "downloads.max_workers", maximum=10),
|
||||
process_timeout_seconds=_number(downloads_raw.get("process_timeout_seconds", 2 * 3600), "downloads.process_timeout_seconds", minimum=1.0),
|
||||
max_height=_integer(downloads_raw.get("max_height", 1080), "downloads.max_height"),
|
||||
export_directory=_relative_directory(
|
||||
downloads_raw.get("export_directory", "exports"),
|
||||
"downloads.export_directory",
|
||||
),
|
||||
export_max_height=_integer(
|
||||
downloads_raw.get("export_max_height", 1080),
|
||||
"downloads.export_max_height",
|
||||
),
|
||||
max_queued_exports=_integer(
|
||||
downloads_raw.get("max_queued_exports", 20),
|
||||
"downloads.max_queued_exports",
|
||||
maximum=1000,
|
||||
),
|
||||
)
|
||||
if downloads.cookie_required and downloads.cookie_path is None:
|
||||
raise ConfigError("downloads.cookie_path is required when cookie_required is true")
|
||||
|
||||
Reference in New Issue
Block a user