update retention policy to a maximum of 2 days for completed archives and adjust related configurations

This commit is contained in:
kstyagi23
2026-09-05 06:37:35 +05:30
parent 48402f7d61
commit 9c1a301c1a
10 changed files with 477 additions and 92 deletions
+12 -2
View File
@@ -4,6 +4,8 @@ import os
from dataclasses import dataclass
from pathlib import Path
MAX_ARCHIVE_RETENTION_DAYS = 2
def _as_bool(name: str, default: bool) -> bool:
value = os.getenv(name)
@@ -59,6 +61,14 @@ class Settings:
data_dir = Path(os.getenv("SITEHARBOR_DATA_DIR", project_root / "data")).expanduser()
if not data_dir.is_absolute():
data_dir = project_root / data_dir
max_retention_days = min(
_as_int("SITEHARBOR_MAX_RETENTION_DAYS", MAX_ARCHIVE_RETENTION_DAYS),
MAX_ARCHIVE_RETENTION_DAYS,
)
default_retention_days = min(
_as_int("SITEHARBOR_DEFAULT_RETENTION_DAYS", MAX_ARCHIVE_RETENTION_DAYS),
max_retention_days,
)
return cls(
project_root=project_root,
@@ -77,8 +87,8 @@ class Settings:
allow_private_networks=_as_bool("SITEHARBOR_ALLOW_PRIVATE_NETWORKS", False),
allow_nonstandard_ports=_as_bool("SITEHARBOR_ALLOW_NONSTANDARD_PORTS", False),
respect_robots=_as_bool("SITEHARBOR_RESPECT_ROBOTS", True),
default_retention_days=_as_int("SITEHARBOR_DEFAULT_RETENTION_DAYS", 7),
max_retention_days=_as_int("SITEHARBOR_MAX_RETENTION_DAYS", 30),
default_retention_days=default_retention_days,
max_retention_days=max_retention_days,
max_pages_cap=_as_int("SITEHARBOR_MAX_PAGES", 1_000),
max_depth_cap=_as_int("SITEHARBOR_MAX_DEPTH", 12),
max_bytes_cap=_as_int("SITEHARBOR_MAX_BYTES", 1024 * 1024 * 1024),