MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / update

Method update

frontend/src/services/uploadService.ts:315–401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

313 }
314
315 update() {
316 for (let i = 0; i < this.task.length; i++) {
317 if (!this.task[i]) continue;
318 if (this.task[i]!.status == "completed") {
319 this.task[i] = undefined;
320 }
321 }
322 if (this.status == "suspend") {
323 if (this.files.size == 0) {
324 this.status = "stopped";
325 }
326 return;
327 }
328 let removeFile = false;
329 for (const task of this.task) {
330 if (!task) continue;
331 if (task.status == "removing") {
332 removeFile = true;
333 }
334 if (task.status == "failed") {
335 task.status = "pending";
336 this.suspend();
337 }
338 }
339 if (this.status == "working" && this.current) {
340 const currentFile = this.files.get(this.current)!;
341 let reachTaskEnd = removeFile;
342
343 if (removeFile) {
344 this.task = [];
345 }
346
347 for (let i = 0; i < UploadService.concurrency; i++) {
348 if (reachTaskEnd || !currentFile.prepared) {
349 break;
350 }
351 if (this.task[i] == undefined) {
352 const nextTask = currentFile.nextTask();
353 if (!nextTask) {
354 reachTaskEnd = true;
355 break;
356 }
357 this.task[i] = nextTask;
358 }
359 }
360
361 let tasks = 0;
362 for (const uploadTask of this.task) {
363 if (!uploadTask) continue;
364 tasks++;
365 if (uploadTask.status != "pending") continue;
366 uploadTask.retries = 0;
367 uploadTask.start(); // async
368 }
369 if (reachTaskEnd && currentFile.prepared && tasks == 0) {
370 const currentFile = this.files.get(this.current)!;
371 currentFile.onEnd();
372 if (!removeFile) {

Callers 5

appendMethod · 0.95
unsuspendMethod · 0.95
initMethod · 0.45
onErrorMethod · 0.45
onCompletedMethod · 0.45

Calls 10

suspendMethod · 0.95
updateProgressMethod · 0.95
nextTaskMethod · 0.80
onEndMethod · 0.80
errorMethod · 0.80
keysMethod · 0.80
startMethod · 0.65
deleteMethod · 0.65
getMethod · 0.45
onStartMethod · 0.45

Tested by

no test coverage detected