fix for file.list api pagination
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user