mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
Merge pull request #583 from zurdi15/hotfix-platform-delete
Platform delete only removes from DB
This commit is contained in:
@@ -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!"}
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
</script>
|
||||
@@ -97,16 +92,6 @@ function closeDialog() {
|
||||
>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider class="border-opacity-25" :thickness="1" />
|
||||
<v-toolbar class="bg-terciary" density="compact">
|
||||
<v-checkbox
|
||||
v-model="deleteFromFs"
|
||||
label="Remove from filesystem"
|
||||
class="ml-3"
|
||||
hide-details
|
||||
/>
|
||||
</v-toolbar>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
@@ -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[] }> {
|
||||
|
||||
Reference in New Issue
Block a user