mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 09:20:18 +08:00
feat: 添加重复任务检查,避免重复下载任务
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
// window.ipcRenderer.on('main-process-message', (_event, ...args) => {
|
// window.ipcRenderer.on('main-process-message', (_event, ...args) => {
|
||||||
// console.log('[Receive Main-process message]:', ...args)
|
// console.log('[Receive Main-process message]:', ...args)
|
||||||
// })
|
// })
|
||||||
|
import pino from 'pino';
|
||||||
|
|
||||||
import { currentApp, currentAppIsInstalled } from "../global/storeConfig";
|
import { currentApp, currentAppIsInstalled } from "../global/storeConfig";
|
||||||
import { APM_STORE_BASE_URL } from "../global/storeConfig";
|
import { APM_STORE_BASE_URL } from "../global/storeConfig";
|
||||||
@@ -9,10 +10,16 @@ import { downloads } from "../global/downloadStatus";
|
|||||||
import { InstallLog, DownloadItem, DownloadResult, App } from '../global/typedefinition';
|
import { InstallLog, DownloadItem, DownloadResult, App } from '../global/typedefinition';
|
||||||
|
|
||||||
let downloadIdCounter = 0;
|
let downloadIdCounter = 0;
|
||||||
|
const logger = pino({ name: 'processInstall.ts' });
|
||||||
|
|
||||||
export const handleInstall = () => {
|
export const handleInstall = () => {
|
||||||
if (!currentApp.value?.pkgname) return;
|
if (!currentApp.value?.pkgname) return;
|
||||||
|
|
||||||
|
if (downloads.value.find(d => d.pkgname === currentApp.value?.pkgname)) {
|
||||||
|
logger.info(`任务已存在,忽略重复添加: ${currentApp.value.pkgname}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
downloadIdCounter += 1;
|
downloadIdCounter += 1;
|
||||||
// 创建下载任务
|
// 创建下载任务
|
||||||
const download: DownloadItem = {
|
const download: DownloadItem = {
|
||||||
@@ -56,6 +63,11 @@ export const handleRetry = (download_: DownloadItem) => {
|
|||||||
export const handleUpgrade = (app: App) => {
|
export const handleUpgrade = (app: App) => {
|
||||||
if (!app.pkgname) return;
|
if (!app.pkgname) return;
|
||||||
|
|
||||||
|
if (downloads.value.find(d => d.pkgname === app.pkgname)) {
|
||||||
|
logger.info(`任务已存在,忽略重复添加: ${app.pkgname}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
downloadIdCounter += 1;
|
downloadIdCounter += 1;
|
||||||
const download: DownloadItem = {
|
const download: DownloadItem = {
|
||||||
id: downloadIdCounter,
|
id: downloadIdCounter,
|
||||||
|
|||||||
Reference in New Issue
Block a user