Deploy to subdirectory
This commit is contained in:
parent
e4a085027b
commit
06e2bc94c3
@ -146,7 +146,7 @@ def clean_ui_subdir(directory: Path):
|
|||||||
logger.info("Removing UI directory content.")
|
logger.info("Removing UI directory content.")
|
||||||
|
|
||||||
for p in reversed(list(directory.glob('**/*'))): # iterate contents from leaves to root
|
for p in reversed(list(directory.glob('**/*'))): # iterate contents from leaves to root
|
||||||
if p.name in ('favicon.ico', 'fallback_file.html'):
|
if p.name in ('.gitkeep', 'fallback_file.html'):
|
||||||
continue
|
continue
|
||||||
if p.is_file():
|
if p.is_file():
|
||||||
p.unlink()
|
p.unlink()
|
||||||
@ -169,6 +169,7 @@ def download_and_install_ui(dest_folder: Path, dl_url: str, version: str):
|
|||||||
|
|
||||||
logger.info(f"Downloading {dl_url}")
|
logger.info(f"Downloading {dl_url}")
|
||||||
resp = requests.get(dl_url).content
|
resp = requests.get(dl_url).content
|
||||||
|
dest_folder.mkdir(parents=True, exist_ok=True)
|
||||||
with ZipFile(BytesIO(resp)) as zf:
|
with ZipFile(BytesIO(resp)) as zf:
|
||||||
for fn in zf.filelist:
|
for fn in zf.filelist:
|
||||||
with zf.open(fn) as x:
|
with zf.open(fn) as x:
|
||||||
@ -207,7 +208,7 @@ def get_ui_download_url() -> Tuple[str, str]:
|
|||||||
|
|
||||||
def start_install_ui(args: Dict[str, Any]) -> None:
|
def start_install_ui(args: Dict[str, Any]) -> None:
|
||||||
|
|
||||||
dest_folder = Path(__file__).parents[1] / 'rpc/api_server/ui'
|
dest_folder = Path(__file__).parents[1] / 'rpc/api_server/ui/installed/'
|
||||||
# First make sure the assets are removed.
|
# First make sure the assets are removed.
|
||||||
dl_url, latest_version = get_ui_download_url()
|
dl_url, latest_version = get_ui_download_url()
|
||||||
|
|
||||||
|
0
freqtrade/rpc/api_server/ui/installed/.gitkeep
Normal file
0
freqtrade/rpc/api_server/ui/installed/.gitkeep
Normal file
@ -20,12 +20,12 @@ async def index_html(rest_of_path: str):
|
|||||||
"""
|
"""
|
||||||
if rest_of_path.startswith('api') or rest_of_path.startswith('.'):
|
if rest_of_path.startswith('api') or rest_of_path.startswith('.'):
|
||||||
raise HTTPException(status_code=404, detail="Not Found")
|
raise HTTPException(status_code=404, detail="Not Found")
|
||||||
uibase = Path(__file__).parent / 'ui'
|
uibase = Path(__file__).parent / 'ui/installed/'
|
||||||
if (uibase / rest_of_path).is_file():
|
if (uibase / rest_of_path).is_file():
|
||||||
return FileResponse(str(uibase / rest_of_path))
|
return FileResponse(str(uibase / rest_of_path))
|
||||||
|
|
||||||
index_file = uibase / 'index.html'
|
index_file = uibase / 'index.html'
|
||||||
if not index_file.is_file():
|
if not index_file.is_file():
|
||||||
return FileResponse(str(uibase / 'fallback_file.html'))
|
return FileResponse(str(uibase.parent / 'fallback_file.html'))
|
||||||
# Fall back to index.html, as indicated by vue router docs
|
# Fall back to index.html, as indicated by vue router docs
|
||||||
return FileResponse(str(index_file))
|
return FileResponse(str(index_file))
|
||||||
|
@ -622,6 +622,9 @@ def test_download_and_install_ui(mocker, tmpdir):
|
|||||||
|
|
||||||
folder = Path(tmpdir) / "uitests_dl"
|
folder = Path(tmpdir) / "uitests_dl"
|
||||||
folder.mkdir(exist_ok=True)
|
folder.mkdir(exist_ok=True)
|
||||||
|
|
||||||
|
assert read_ui_version(folder) is None
|
||||||
|
|
||||||
download_and_install_ui(folder, 'http://whatever.xxx/download/file.zip', '22')
|
download_and_install_ui(folder, 'http://whatever.xxx/download/file.zip', '22')
|
||||||
|
|
||||||
assert wb_mock.call_count == 2
|
assert wb_mock.call_count == 2
|
||||||
|
Loading…
Reference in New Issue
Block a user