fix for file.list api pagination

This commit is contained in:
2025-06-26 17:13:06 +09:00
parent fffb686023
commit 95f22ea5f9
13 changed files with 107 additions and 38 deletions

View File

@ -1,5 +1,6 @@
import os
from typing import IO, Any
from urllib.parse import parse_qs, urlparse
if os.name == "nt":
import msvcrt
@ -21,3 +22,10 @@ class FileLock:
msvcrt.locking(file.fileno(), msvcrt.LK_UNLCK, 1)
elif os.name == "posix":
fcntl.flock(file.fileno(), fcntl.LOCK_UN)
def page_num_from_url(url: str) -> int | None:
parsed_url = urlparse(url)
params = parse_qs(parsed_url.query)
page = params.get("page", [None])[0]
return int(page) if page is not None else None