Reduce API startup storage prewarm
This commit is contained in:
@@ -105,8 +105,11 @@ class FileStorage:
|
||||
directory = self._collection_dir(collection)
|
||||
if not directory.exists():
|
||||
return []
|
||||
if limit is not None and limit <= 0:
|
||||
return []
|
||||
documents: list[dict[str, Any]] = []
|
||||
for path in sorted(directory.glob("*.json")):
|
||||
paths = directory.glob("*.json") if limit is not None else sorted(directory.glob("*.json"))
|
||||
for path in paths:
|
||||
try:
|
||||
documents.append(orjson.loads(path.read_bytes()))
|
||||
except (FileNotFoundError, orjson.JSONDecodeError):
|
||||
|
||||
@@ -585,7 +585,7 @@ def _load_persisted_state() -> None:
|
||||
_rbac.users[access.user_id] = access
|
||||
for payload in _storage.list_documents("privacy_markers"):
|
||||
_privacy.upsert_marker(PrivacyMarker.model_validate(payload))
|
||||
version_load_limit = int(os.environ.get("SFERA_STARTUP_OBJECT_VERSION_LIMIT", "5000"))
|
||||
version_load_limit = int(os.environ.get("SFERA_STARTUP_OBJECT_VERSION_LIMIT", "0"))
|
||||
for payload in _storage.list_documents("object_versions", limit=version_load_limit):
|
||||
_versions.upsert_version(SemanticObjectVersion.model_validate(payload))
|
||||
|
||||
@@ -2338,10 +2338,10 @@ async def download_windows_agent_cmd_installer(request: Request, agent_id: str |
|
||||
if agent_id:
|
||||
installer_url = f"{installer_url}?agent_id={quote(agent_id, safe='')}"
|
||||
escaped_installer_url = installer_url.replace("%", "%%")
|
||||
script = f"""@echo off
|
||||
script = fr"""@echo off
|
||||
setlocal
|
||||
set "INSTALLER_URL={escaped_installer_url}"
|
||||
set "INSTALLER=%TEMP%\\install-sfera-windows-agent.ps1"
|
||||
set "INSTALLER=%TEMP%\install-sfera-windows-agent.ps1"
|
||||
echo Downloading SFERA Windows Agent installer...
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -UseBasicParsing -Uri $env:INSTALLER_URL -OutFile $env:INSTALLER"
|
||||
if errorlevel 1 (
|
||||
|
||||
Reference in New Issue
Block a user