🐛 Prevent some scenario to delete user entire computer
This commit is contained in:
		| @@ -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) | ||||
|  | ||||
|   | ||||
| @@ -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 { | ||||
|               </Typography> | ||||
|             </Box> | ||||
|  | ||||
|             <Divider sx={{ mb: 2 }} /> | ||||
|  | ||||
|             <Typography variant="h6" component="h2" gutterBottom> | ||||
|               Release Information | ||||
|             </Typography> | ||||
|  | ||||
|             {appReleaseContent && ( | ||||
|               <Box | ||||
|                 component="article" | ||||
|                 className="prose prose-lg dark:prose-invert" | ||||
|                 dangerouslySetInnerHTML={{ __html: appReleaseContent ?? '' }} | ||||
|               /> | ||||
|             )} | ||||
|  | ||||
|             <Divider sx={{ mb: 2 }} /> | ||||
|  | ||||
|             <Typography variant="h6" component="h2" gutterBottom> | ||||
|               Product Introduction | ||||
|             </Typography> | ||||
|  | ||||
|             {appProductContent && ( | ||||
|               <Box | ||||
|                 component="article" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user