This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/main by this push:
     new 2fb4d70  Add a migration to use a cache state subdirectory
2fb4d70 is described below

commit 2fb4d700914d32d1223a96b73003d74d30558e0e
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Jan 15 19:49:42 2026 +0000

    Add a migration to use a cache state subdirectory
---
 atr/blueprints/__init__.py |  3 ++-
 atr/server.py              | 13 +++++++++++++
 atr/util.py                |  4 ++--
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/atr/blueprints/__init__.py b/atr/blueprints/__init__.py
index a0f1318..e8be74e 100644
--- a/atr/blueprints/__init__.py
+++ b/atr/blueprints/__init__.py
@@ -58,5 +58,6 @@ def _check_blueprint(module: ModuleType, routes: list[str]) 
-> None:
 
 
 def _export_routes(state_dir: pathlib.Path) -> None:
-    routes_file = state_dir / "routes.json"
+    routes_file = state_dir / "cache" / "routes.json"
+    routes_file.parent.mkdir(parents=True, exist_ok=True)
     routes_file.write_text(json.dumps(sorted(_all_routes), indent=2))
diff --git a/atr/server.py b/atr/server.py
index 02bf06f..e22eb3d 100644
--- a/atr/server.py
+++ b/atr/server.py
@@ -113,6 +113,7 @@ def _app_dirs_setup(app_config: type[config.AppConfig]) -> 
None:
 
     directories_to_ensure = [
         pathlib.Path(app_config.STATE_DIR) / "audit",
+        pathlib.Path(app_config.STATE_DIR) / "cache",
         util.get_downloads_dir(),
         util.get_finished_dir(),
         util.get_tmp_dir(),
@@ -491,6 +492,17 @@ def _migrate_audit(state_dir: pathlib.Path) -> None:
     )
 
 
+def _migrate_cache(state_dir: pathlib.Path) -> None:
+    _migrate_file(
+        state_dir / "routes.json",
+        state_dir / "cache" / "routes.json",
+    )
+    _migrate_file(
+        state_dir / "user_session_cache.json",
+        state_dir / "cache" / "user_session_cache.json",
+    )
+
+
 def _migrate_directory(old_path: pathlib.Path, new_path: pathlib.Path) -> None:
     if old_path.exists() and (not new_path.exists()):
         old_path.rename(new_path)
@@ -522,6 +534,7 @@ def _migrate_state_directory(app_config: 
type[config.AppConfig]) -> None:
         fcntl.flock(lock_file, fcntl.LOCK_EX)
         try:
             _migrate_audit(state_dir)
+            _migrate_cache(state_dir)
         finally:
             fcntl.flock(lock_file, fcntl.LOCK_UN)
 
diff --git a/atr/util.py b/atr/util.py
index 6176c2a..c796831 100644
--- a/atr/util.py
+++ b/atr/util.py
@@ -825,7 +825,7 @@ def release_directory_version(release: sql.Release) -> 
pathlib.Path:
 
 
 async def session_cache_read() -> dict[str, dict]:
-    cache_path = pathlib.Path(config.get().STATE_DIR) / 
"user_session_cache.json"
+    cache_path = pathlib.Path(config.get().STATE_DIR) / "cache" / 
"user_session_cache.json"
     try:
         async with aiofiles.open(cache_path) as f:
             content = await f.read()
@@ -837,7 +837,7 @@ async def session_cache_read() -> dict[str, dict]:
 
 
 async def session_cache_write(cache_data: dict[str, dict]) -> None:
-    cache_path = pathlib.Path(config.get().STATE_DIR) / 
"user_session_cache.json"
+    cache_path = pathlib.Path(config.get().STATE_DIR) / "cache" / 
"user_session_cache.json"
     await atomic_write_file(cache_path, json.dumps(cache_data, indent=2))
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to