| 109 | // Extract all files from the hierarchical file tree |
| 110 | |
| 111 | const extractFiles = (nodes: any[], result: any[] = []) => { |
| 112 | for (const node of nodes) { |
| 113 | if (node.type === 'file' || node.type === 'blob') { |
| 114 | result.push({ |
| 115 | path: node.path, |
| 116 | type: 'blob', |
| 117 | size: node.size || 0 |
| 118 | }); |
| 119 | } else if ((node.type === 'directory' || node.type === 'tree') && node.children) { |
| 120 | extractFiles(node.children, result); |
| 121 | } |
| 122 | } |
| 123 | return result; |
| 124 | }; |
| 125 | files = extractFiles(structureData.fileTree); |
| 126 | } else if (structureData.tree && Array.isArray(structureData.tree)) { |
| 127 | files = structureData.tree.filter((item: any) => item.type === 'blob' || item.type === 'file'); |