From 957d06e883cc6d661860278ddaa17c20bd5d8e2d Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Mon, 8 Jan 2024 15:11:29 -0500 Subject: [PATCH] Platform delete only removes from DB --- backend/endpoints/platform.py | 15 +-------------- backend/utils/fs.py | 8 -------- .../Dialog/Platform/DeletePlatform.vue | 17 +---------------- frontend/src/services/api.ts | 6 +----- 4 files changed, 3 insertions(+), 43 deletions(-) diff --git a/backend/endpoints/platform.py b/backend/endpoints/platform.py index 480b6e86f..c6d776070 100644 --- a/backend/endpoints/platform.py +++ b/backend/endpoints/platform.py @@ -3,8 +3,6 @@ from pydantic import BaseModel from typing import Optional from typing_extensions import TypedDict from handler import dbh -from exceptions.fs_exceptions import PlatformNotFoundException -from utils.fs import remove_platform from utils.oauth import protected_route from config import ROMM_HOST from logger.logger import log @@ -127,9 +125,7 @@ class DeletePlatformResponse(TypedDict): @protected_route(router.delete, "/platforms/{fs_slug}", ["platforms.write"]) -def delete_platform( - request: Request, fs_slug: str, delete_from_fs: bool = False -) -> DeletePlatformResponse: +def delete_platform(request: Request, fs_slug) -> DeletePlatformResponse: """Detele platform from database [and filesystem]""" platform = dbh.get_platform_by_fs_slug(fs_slug) @@ -141,13 +137,4 @@ def delete_platform( log.info(f"Deleting {platform.name} [{platform.fs_slug}] from database") dbh.delete_platform(platform.slug) - if delete_from_fs: - log.info(f"Deleting {platform.name} [{platform.fs_slug}] from filesystem") - try: - remove_platform(fs_slug) - except PlatformNotFoundException as e: - error = f"Couldn't delete from filesystem: {str(e)}" - log.error(error) - raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=error) - return {"msg": f"{platform.name} - [{platform.fs_slug}] deleted successfully!"} diff --git a/backend/utils/fs.py b/backend/utils/fs.py index 22c76fcc6..79c7bee9e 100644 --- a/backend/utils/fs.py +++ b/backend/utils/fs.py @@ -218,14 +218,6 @@ def get_platforms() -> list[str]: raise PlatformsNotFoundException from exc -def remove_platform(fs_slug: str): - platform_path = get_roms_structure(fs_slug) - try: - shutil.rmtree(f"{LIBRARY_BASE_PATH}/{platform_path}") - except FileNotFoundError as exc: - raise PlatformNotFoundException(fs_slug) from exc - - # ========= Roms utils ========= def get_roms_structure(fs_slug: str): return ( diff --git a/frontend/src/components/Dialog/Platform/DeletePlatform.vue b/frontend/src/components/Dialog/Platform/DeletePlatform.vue index 7b4c50a7c..cbcf386c1 100644 --- a/frontend/src/components/Dialog/Platform/DeletePlatform.vue +++ b/frontend/src/components/Dialog/Platform/DeletePlatform.vue @@ -15,17 +15,13 @@ emitter?.on("showDeletePlatformDialog", (platformToDelete) => { platform.value = platformToDelete; show.value = true; }); -const deleteFromFs = ref(false); async function deletePlatform() { if (!platform.value) return; show.value = false; await api - .deletePlatform({ - platform: platform.value, - deleteFromFs: deleteFromFs.value, - }) + .deletePlatform({ platform: platform.value }) .then((response) => { emitter?.emit("snackbarShow", { msg: response.data.msg, @@ -51,7 +47,6 @@ async function deletePlatform() { } function closeDialog() { - deleteFromFs.value = false; show.value = false; } @@ -97,16 +92,6 @@ function closeDialog() { > - - - - - diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index 8b5514299..91212453d 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -37,14 +37,10 @@ async function fetchPlatforms(): Promise<{ data: PlatformSchema[] }> { async function deletePlatform({ platform, - deleteFromFs = false, }: { platform: PlatformSchema; - deleteFromFs: boolean; }): Promise<{ data: DeletePlatformResponse }> { - return api.delete(`/platforms/${platform.fs_slug}`, { - params: { delete_from_fs: deleteFromFs }, - }); + return api.delete(`/platforms/${platform.fs_slug}`); } async function fetchRecentRoms(): Promise<{ data: RomSchema[] }> {