MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / processFile

Function processFile

src/lib/installPlugin.js:181–227  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

179 const limit = 2;
180
181 async function processFile(file) {
182 try {
183 const entry = zip.files[file];
184
185 let correctFile = file.replace(/\\/g, "/");
186 const isDirEntry = entry.dir || correctFile.endsWith("/");
187
188 if (isUnsafeAbsolutePath(file)) {
189 ignoredUnsafeEntries.add(file);
190 return;
191 }
192
193 correctFile = sanitizeZipPath(correctFile, isDirEntry);
194 if (!correctFile) return;
195
196 const fileUrl = Url.join(pluginDir, correctFile);
197
198 // Handle directory entries
199 if (isDirEntry) {
200 await createFileRecursive(pluginDir, correctFile, true);
201 return;
202 }
203
204 // Ensure parent directory exists
205 const lastSlash = correctFile.lastIndexOf("/");
206 if (lastSlash !== -1) {
207 const parentRel = correctFile.slice(0, lastSlash + 1);
208 await createFileRecursive(pluginDir, parentRel, true);
209 }
210
211 if (!state.exists(correctFile)) {
212 await createFileRecursive(pluginDir, correctFile, false);
213 }
214
215 let data = await entry.async("ArrayBuffer");
216
217 if (file === "plugin.json") {
218 data = JSON.stringify(pluginJson);
219 }
220
221 if (!(await state.isUpdated(correctFile, data))) return;
222
223 await fsOperation(fileUrl).writeFile(data);
224 } catch (error) {
225 console.error(`Error processing file ${file}:`, error);
226 }
227 }
228
229 // Process in batches
230 for (let i = 0; i < files.length; i += limit) {

Callers

nothing calls this directly

Calls 9

isUnsafeAbsolutePathFunction · 0.85
sanitizeZipPathFunction · 0.85
createFileRecursiveFunction · 0.85
fsOperationFunction · 0.85
addMethod · 0.80
isUpdatedMethod · 0.80
existsMethod · 0.65
writeFileMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected