INNER CODE UNIT · Python
_write_state_file
arvin341az-glitch/RVG · main.py:199
async def _write_state_file(payload: str):
DATA_DIR.mkdir(parents=True, exist_ok=True)
tmp = DATA_FILE.with_suffix(".tmp")
async with aiofiles.open(tmp, "w", encoding="utf-8") as f:
await f.write(payload)
tmp.replace(DATA_FILE)
def _get_or_create_secret() -> str:
env_secret = os.environ.get("SECRET_KEY")
if env_secret:
return env_secret
try:
DATA_DIR.mkdir(parents=True, exist_ok=True)
if SECRET_FILE.exists():
val = SECRET_FILE.read_text(encoding="utf-8").strip()
if val:
return val