MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / processFile

Function processFile

scan-worker.js:316–348  ·  view source on GitHub ↗
(filePath, fileName)

Source from the content-addressed store, hash-verified

314 const donePromise = new Promise(resolve => { resolveDone = resolve; });
315
316 const processNext = () => {
317 // If no active ops and queue is empty, we are done
318 if (activeOps === 0 && queue.length === 0) {
319 if (traversedFileEntries > 0) {
320 parentPort.postMessage({
321 type: 'progress',
322 processed: traversedFileEntries
323 });
324 }
325 flushDiscoveredFiles(true);
326 resolveDone({ files: [], totalFiles: traversedFileEntries, skippedDueToSize });
327 return;
328 }
329
330 // While we have capacity and items in queue, start processing
331 while (activeOps < MAX_CONCURRENT_OPS && queue.length > 0) {
332 const item = queue.shift();
333 activeOps++;
334
335 if (item.type === 'dir') {
336 processDirectory(item.path).finally(() => {
337 activeOps--;
338 processNext();
339 });
340 } else if (item.type === 'file') {
341 processFile(item.path, item.name).finally(() => {
342 activeOps--;
343 processNext();
344 });
345 }
346 }
347 };
348
349 const processDirectory = async (dirPath) => {
350 if (isExcludedDir(dirPath, excludedDirs)) {
351 console.log(`Skipping excluded directory ${dirPath}`);

Callers 1

processNextFunction · 0.70

Calls 1

scanZipFileFunction · 0.85

Tested by

no test coverage detected