change: security-check, memory-check [untest]

- fix high risk security issues
- fix high memory usage
- change adb to connection pool single instance

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-06-22 10:55:47 +07:00
parent f0619c5a10
commit 4f464a8513
23 changed files with 413 additions and 73 deletions

View file

@ -7,6 +7,7 @@
import { onMount, onDestroy } from 'svelte';
import * as adb from '$lib/core/adb/adb';
import { adbConnectionStatus } from '$lib/core/stores/adbConnectionStore';
import { addNotification } from '$lib/core/stores/noti';
import { columns, type RecipeOverview } from '../../recipe/overview/columns';
import {
@ -72,7 +73,7 @@
// clear out event
GlobalEventBus.on('recipe-event', (d: any) => {
const unsubRecipeEvent = GlobalEventBus.on('recipe-event', (d: any) => {
logger.info('[recipe-ev] get event: ', d);
if (d?.type == 'load-recipe' && d?.status == 'end') {
addNotification('INFO:Get data, waiting for reloading ...');
@ -829,6 +830,7 @@
});
onDestroy(() => {
unsubRecipeEvent();
clearOnMenuSavedCallback();
});

View file

@ -10,6 +10,7 @@
import { goto } from '$app/navigation';
import * as adb from '$lib/core/adb/adb';
import { adbConnectionStatus } from '$lib/core/stores/adbConnectionStore';
import { addNotification } from '$lib/core/stores/noti';
import { referenceFromPage } from '$lib/core/stores/recipeStore';
import { env } from '$env/dynamic/public';
@ -295,21 +296,12 @@
async function connectAdb() {
try {
if (adb.getAdbInstance()) {
const connected = await adb.ensureAdbConnection();
if (connected) {
if (!isAdbWriterAvailable()) {
await adb.reconnectAndroidRecipeMenuServer();
}
await loadRecipeFromMachine();
return;
}
if (!('usb' in navigator)) {
throw new Error('WebUSB not supported');
}
await adb.connectRecipeMenuViaWebUSB();
if (adb.getAdbInstance()) {
await loadRecipeFromMachine();
}
} catch (e: any) {
addNotification(`ERROR:${e}`);