From 3489203a16646f51b14987fdaccaed0554c31f43 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 11 Jan 2025 22:06:54 +0800 Subject: [PATCH] :bug: Prevent some scenario to delete user entire computer --- src/main/installer.ts | 12 +++++++++++- src/renderer/src/pages/library/Details.tsx | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/installer.ts b/src/main/installer.ts index f5a015e..59526be 100644 --- a/src/main/installer.ts +++ b/src/main/installer.ts @@ -3,11 +3,12 @@ import { exec } from 'child_process' import { join } from 'path' import { ipcMain, WebContents } from 'electron' import { glob } from 'glob' -import { unlinkSync } from 'fs' +import { mkdirSync, statSync, unlinkSync } from 'fs' import { installTasks, InstallTask, updateInstallTask, InstallProgressPeriod } from './tasks' import { downloadAssets } from './downloader' import { setAppRecord } from './library' +import { readdirSync } from 'original-fs' export function initInstaller(): void { ipcMain.handle('install-product-release', (evt, task: string) => submitInstallTask(JSON.parse(task), evt.sender)) @@ -18,6 +19,15 @@ function submitInstallTask(task: InstallTask, contents: WebContents): void { task.progress = { value: 0, period: InstallProgressPeriod.Initializing, done: false, error: null } task.emitter = contents + if (!statSync(task.basePath).isDirectory()) { + return + } + if (readdirSync(task.basePath).length > 0) { + const newPath = join(task.basePath, task.product.name) + mkdirSync(newPath) + task.basePath = newPath + } + installTasks[task.id] = task updateInstallTask(task) diff --git a/src/renderer/src/pages/library/Details.tsx b/src/renderer/src/pages/library/Details.tsx index a548e1d..1eebaf8 100644 --- a/src/renderer/src/pages/library/Details.tsx +++ b/src/renderer/src/pages/library/Details.tsx @@ -1,5 +1,5 @@ import { LocalAppRecord } from '@main/library' -import { Avatar, Box, Button, Container, Grid2 as Grid, IconButton, Stack, Typography } from '@mui/material' +import { Avatar, Box, Button, Container, Divider, Grid2 as Grid, IconButton, Stack, Typography } from '@mui/material' import { useEffect, useMemo, useState } from 'react' import { useNavigate, useParams } from 'react-router' import { getAttachmentUrl } from 'solar-js-sdk' @@ -84,6 +84,26 @@ export default function LibraryDetails(): JSX.Element { + + + + Release Information + + + {appReleaseContent && ( + + )} + + + + + Product Introduction + + {appProductContent && (