don't expose CLIENT constant
This commit is contained in:
parent
b28d6fa4e7
commit
eb69fa4ec6
3 changed files with 18 additions and 6 deletions
|
@ -1,9 +1,21 @@
|
|||
from webdav3.client import Client
|
||||
import functools
|
||||
from typing import Any
|
||||
|
||||
from webdav3.client import Client, Resource
|
||||
|
||||
from .config import SETTINGS
|
||||
|
||||
CLIENT = Client({
|
||||
_WEBDAV_CLIENT = Client({
|
||||
"webdav_hostname": SETTINGS.webdav_url,
|
||||
"webdav_login": SETTINGS.dav_username,
|
||||
"webdav_password": SETTINGS.dav_password,
|
||||
})
|
||||
|
||||
|
||||
@functools.lru_cache
|
||||
def webdav_resource(remote_path: Any) -> Resource:
|
||||
return _WEBDAV_CLIENT.resource(remote_path)
|
||||
|
||||
|
||||
def webdav_list(remote_path: str) -> list:
|
||||
return _WEBDAV_CLIENT.list(remote_path)
|
||||
|
|
|
@ -8,7 +8,7 @@ from typing import Any, Optional
|
|||
from async_lru import alru_cache
|
||||
from webdav3.client import Resource
|
||||
|
||||
from . import CLIENT
|
||||
from . import webdav_resource
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -53,7 +53,7 @@ async def _get_buffer(
|
|||
resource.write_to(buffer)
|
||||
return buffer
|
||||
|
||||
resource = CLIENT.resource(remote_path)
|
||||
resource = webdav_resource(remote_path)
|
||||
return await buffer_inner(resource)
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from typing import Iterator
|
|||
from fastapi import HTTPException, status
|
||||
from webdav3.exceptions import RemoteResourceNotFound
|
||||
|
||||
from .. import CLIENT
|
||||
from .. import webdav_list
|
||||
from ..dav_file import DavFile
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ class FileNameLister:
|
|||
|
||||
def __call__(self) -> Iterator[str]:
|
||||
try:
|
||||
file_names = CLIENT.list(self.remote_path)
|
||||
file_names = webdav_list(self.remote_path)
|
||||
|
||||
return (
|
||||
name
|
||||
|
|
Loading…
Reference in a new issue