This commit is contained in:
1 parent
fae1c3a3de
commit
b456109c2d
2 files changed
+19
-3
No files matched your search
+15
-1
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user