Commit 806135b

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-05-10 05:03:17
fix(database): return succ code for `list_cf_r2` function
1 parent 88542d4
Changed files (1)
src/database.py
@@ -79,11 +79,11 @@ async def get_cf_kv(key: str, *, log_success: bool = True) -> dict:
     return {}
 
 
-async def list_cf_r2(prefix: str = "", continuation_token: str | None = None) -> dict:
+async def list_cf_r2(prefix: str = "", continuation_token: str | None = None) -> tuple[bool, dict]:
     """Get from Cloudflare R2."""
     if not DB.CF_R2_ENABLED:
         logger.warning("SKIP LIST CF-R2: Cloudflare R2 disabled")
-        return {}
+        return False, {}
     async with Session().client(
         service_name="s3",
         endpoint_url=f"https://{DB.CF_ACCOUNT_ID}.r2.cloudflarestorage.com",
@@ -97,10 +97,10 @@ async def list_cf_r2(prefix: str = "", continuation_token: str | None = None) ->
         if prefix:
             payload["Prefix"] = prefix
         try:
-            return await s3.list_objects_v2(**payload)
+            return True, await s3.list_objects_v2(**payload)
         except Exception as e:
             logger.warning(f"List CF-R2 failed for {prefix=}: {e}")
-    return {}
+    return False, {}
 
 
 async def get_cf_r2(key: str) -> dict: