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

Function selectedFiles

frontend/src/hooks/useFileManager.ts:647–721  ·  view source on GitHub ↗
(files: File[], overridePath?: string)

Source from the content-addressed store, hash-verified

645 };
646
647 const selectedFiles = async (files: File[], overridePath?: string) => {
648 const { state: missionCfg, execute: getUploadMissionCfg } = uploadAddress();
649 const targetPath = overridePath || currentPath.value;
650 const uploadQueue: SelectedUploadFile[] = files.map((file) => ({ file, overwrite: false }));
651
652 try {
653 const occupiedNames = await getExistingUploadNames(uploadQueue, targetPath);
654 const confirmedFiles: SelectedUploadFile[] = [];
655 let sharedDecision: Omit<UploadConflictDecision, "applyToAll"> | undefined;
656
657 for (let i = 0; i < uploadQueue.length; i++) {
658 const item = uploadQueue[i];
659 const fileName = item.file.name;
660 const hasConflict = occupiedNames.has(fileName);
661
662 if (hasConflict) {
663 const decision = sharedDecision
664 ? { ...sharedDecision, applyToAll: true }
665 : await confirmUploadConflict(
666 fileName,
667 countRemainingUploadConflicts(uploadQueue, i, occupiedNames)
668 );
669
670 if (decision.applyToAll) {
671 sharedDecision = {
672 keep: decision.keep,
673 action: decision.action
674 };
675 }
676
677 if (!decision.keep || decision.action === "skip") continue;
678 item.overwrite = decision.action === "overwrite";
679 }
680
681 confirmedFiles.push(item);
682 occupiedNames.add(fileName);
683 }
684
685 for (const f of confirmedFiles) {
686 try {
687 await getUploadMissionCfg({
688 params: {
689 upload_dir: targetPath,
690 daemonId: daemonId!,
691 uuid: instanceId!,
692 file_name: f.file.name
693 }
694 });
695 if (!missionCfg.value) throw new Error(t("TXT_CODE_e8ce38c2"));
696
697 const addr = parseForwardAddress(getFileConfigAddr(missionCfg.value), "http");
698 uploadService.append(
699 f.file,
700 addr,
701 missionCfg.value.password,
702 {
703 overwrite: f.overwrite
704 },

Callers 2

onFileChangeFunction · 0.85
onOkFunction · 0.85

Calls 10

parseForwardAddressFunction · 0.90
reportErrorMsgFunction · 0.90
getExistingUploadNamesFunction · 0.85
confirmUploadConflictFunction · 0.85
getFileConfigAddrFunction · 0.85
addMethod · 0.80
errorMethod · 0.80
pushMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected