1
0
mirror of https://github.com/etesync/server synced 2024-11-18 23:08:08 +00:00

Update code to adjust to most recent python/fastapi.

This commit is contained in:
Tom Hacohen 2024-06-08 20:27:13 -04:00
parent 0be14a7b0e
commit 138d99dd7f

View File

@ -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: