mirror of
https://github.com/etesync/server
synced 2024-12-27 09:48:24 +00:00
Update code to adjust to most recent python/fastapi.
This commit is contained in:
parent
0be14a7b0e
commit
138d99dd7f
@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import os
|
||||
from functools import lru_cache
|
||||
from importlib import import_module
|
||||
from pathlib import Path, PurePath
|
||||
@ -32,9 +33,7 @@ def _convert_file_to_url(path):
|
||||
path_obj = PurePath(path)
|
||||
|
||||
relpath = path_obj.relative_to(path_root)
|
||||
# Python 3.5: Path.resolve() has no `strict` kwarg, so use pathmod from an
|
||||
# already instantiated Path object
|
||||
url = relpath._flavour.pathmod.normpath(str(url_root / relpath))
|
||||
url = os.path.normpath(str(url_root / relpath))
|
||||
|
||||
return quote(str(url))
|
||||
|
||||
@ -48,9 +47,7 @@ def _sanitize_path(filepath):
|
||||
filepath_obj = Path(filepath)
|
||||
|
||||
# get absolute path
|
||||
# Python 3.5: Path.resolve() has no `strict` kwarg, so use pathmod from an
|
||||
# already instantiated Path object
|
||||
filepath_abs = Path(filepath_obj._flavour.pathmod.normpath(str(path_root / filepath_obj)))
|
||||
filepath_abs = Path(os.path.normpath(str(path_root / filepath_obj)))
|
||||
|
||||
# if filepath_abs is not relative to path_root, relative_to throws an error
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user