Upload files to "tracking"

This commit is contained in:
2026-07-24 15:25:04 +00:00
parent ba44d1bc45
commit 2ed0761342
4 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import json
import os
import threading
_LOCK = threading.Lock()
_PATH = os.path.join(os.path.dirname(__file__), "password_resets.json")
def _read():
try:
with open(_PATH, "r") as f:
return set(json.load(f))
except (FileNotFoundError, json.JSONDecodeError):
return set()
def _write(ids):
with open(_PATH, "w") as f:
json.dump(sorted(ids), f)
def mark_password_set(pid: int):
with _LOCK:
ids = _read()
ids.add(pid)
_write(ids)
def clear_password_set(pid: int):
with _LOCK:
ids = _read()
ids.discard(pid)
_write(ids)
def has_real_password(pid: int) -> bool:
with _LOCK:
return pid in _read()