From b456109c2d89f95cc7342ff1d7a63e58311fa3d9 Mon Sep 17 00:00:00 2001 From: Sucukdeluxe <259325684+Sucukdeluxe@users.noreply.github.com> Date: Fri, 16 Oct 2026 05:40:01 +0200 Subject: [PATCH] Preserve explicit upload cancellations across MCP updates --- lib/mcp-update.js | 16 +++++++++++++++- main.js | 6 ++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/mcp-update.js b/lib/mcp-update.js index 6348775..7b0a280 100644 --- a/lib/mcp-update.js +++ b/lib/mcp-update.js @@ -57,7 +57,7 @@ class McpUpdate { blocksTransfers() { const job = this.active(); return !!job && job.phase !== 'awaiting_reconnect'; } public(job) { if (!job) return null; - const { owner: _owner, requestKey: _key, resume: _resume, ...value } = job; + const { owner: _owner, requestKey: _key, resume: _resume, excludedJobIds: _excluded, ...value } = job; return value; } status(args, context) { @@ -73,6 +73,19 @@ class McpUpdate { Object.assign(job, patch, { phase, updatedAt: Date.now() }); await this.save(); } + async excludeResumeJobs(jobIds) { + const job = this.active(); + if (!job) return; + if (jobIds === null) job.resumeSuppressed = true; + else job.excludedJobIds = [...new Set([...(job.excludedJobIds || []), ...jobIds])].slice(-50000); + if (job.resume) this.filterResume(job); + await this.save(); + } + filterResume(job) { + const excluded = new Set(job.excludedJobIds || []); + job.resume.jobIds = (job.resume.jobIds || []).filter(id => !excluded.has(id)); + if (job.resumeSuppressed) job.resume.wasUploading = false; + } async start({ targetVersion, requestKey }, context) { this.assertAllowed(); if (!VERSION.test(targetVersion)) throw new McpAccessError('INVALID_ARGUMENTS'); @@ -110,6 +123,7 @@ class McpUpdate { if (prepared.remoteVersion !== job.targetVersion || !prepared.sha512Verified || !prepared.sha512) throw new McpAccessError('UPDATE_INTEGRITY_REQUIRED'); await this.phase(job, 'waiting_uploads', { sha512: prepared.sha512 }); job.resume = await this.options.park(); + this.filterResume(job); await this.save(); parked = true; await this.options.drain(() => this.assertAllowed()); diff --git a/main.js b/main.js index 3eb7f7f..94f4870 100644 --- a/main.js +++ b/main.js @@ -2928,17 +2928,19 @@ function logMemorySnapshot(label) { } catch {} } -ipcMain.handle('cancel-upload', () => { +ipcMain.handle('cancel-upload', async () => { if (uploadManager) { uploadManager.cancel(); } + await mcpUpdate.excludeResumeJobs(null); return true; }); -ipcMain.handle('cancel-selected-jobs', (_event, jobIds) => { +ipcMain.handle('cancel-selected-jobs', async (_event, jobIds) => { if (uploadManager) { uploadManager.cancelJobs(Array.isArray(jobIds) ? jobIds : []); } + await mcpUpdate.excludeResumeJobs(Array.isArray(jobIds) ? jobIds.filter(id => typeof id === 'string') : []); return true; });