Preserve explicit upload cancellations across MCP updates
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-10-16 05:40:01 +02:00
1 parent fae1c3a3de
commit b456109c2d
2 files changed
+19 -3

No files matched your search

+15 -1
View File
@@ -57,7 +57,7 @@ class McpUpdate {
blocksTransfers() { const job = this.active(); return !!job && job.phase !== 'awaiting_reconnect'; } blocksTransfers() { const job = this.active(); return !!job && job.phase !== 'awaiting_reconnect'; }
public(job) { public(job) {
if (!job) return null; 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; return value;
} }
status(args, context) { status(args, context) {
@@ -73,6 +73,19 @@ class McpUpdate {
Object.assign(job, patch, { phase, updatedAt: Date.now() }); Object.assign(job, patch, { phase, updatedAt: Date.now() });
await this.save(); 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) { async start({ targetVersion, requestKey }, context) {
this.assertAllowed(); this.assertAllowed();
if (!VERSION.test(targetVersion)) throw new McpAccessError('INVALID_ARGUMENTS'); 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'); if (prepared.remoteVersion !== job.targetVersion || !prepared.sha512Verified || !prepared.sha512) throw new McpAccessError('UPDATE_INTEGRITY_REQUIRED');
await this.phase(job, 'waiting_uploads', { sha512: prepared.sha512 }); await this.phase(job, 'waiting_uploads', { sha512: prepared.sha512 });
job.resume = await this.options.park(); job.resume = await this.options.park();
this.filterResume(job);
await this.save(); await this.save();
parked = true; parked = true;
await this.options.drain(() => this.assertAllowed()); await this.options.drain(() => this.assertAllowed());
+4 -2
View File
@@ -2928,17 +2928,19 @@ function logMemorySnapshot(label) {
} catch {} } catch {}
} }
ipcMain.handle('cancel-upload', () => { ipcMain.handle('cancel-upload', async () => {
if (uploadManager) { if (uploadManager) {
uploadManager.cancel(); uploadManager.cancel();
} }
await mcpUpdate.excludeResumeJobs(null);
return true; return true;
}); });
ipcMain.handle('cancel-selected-jobs', (_event, jobIds) => { ipcMain.handle('cancel-selected-jobs', async (_event, jobIds) => {
if (uploadManager) { if (uploadManager) {
uploadManager.cancelJobs(Array.isArray(jobIds) ? jobIds : []); uploadManager.cancelJobs(Array.isArray(jobIds) ? jobIds : []);
} }
await mcpUpdate.excludeResumeJobs(Array.isArray(jobIds) ? jobIds.filter(id => typeof id === 'string') : []);
return true; return true;
}); });