Den Graph-Baum rekursiv abfragen, so wie die Oberflaeche es tut.
(port, path = '', seen = new Set(), files = new Set(), dirs = new Set())
| 218 | |
| 219 | /** Den Graph-Baum rekursiv abfragen, so wie die Oberflaeche es tut. */ |
| 220 | async function graphFiles(port, path = '', seen = new Set(), files = new Set(), dirs = new Set()) { |
| 221 | if (seen.has(path)) { |
| 222 | return { files, dirs }; |
| 223 | } |
| 224 | seen.add(path); |
| 225 | const query = new URLSearchParams({ project: PROJECT }); |
| 226 | if (path.length > 0) { |
| 227 | query.set('path', path); |
| 228 | } |
| 229 | const response = await fetch(`http://127.0.0.1:${port}/api/tree?${query.toString()}`, { |
| 230 | headers: { Accept: 'application/json' }, |
| 231 | }); |
| 232 | const body = await response.json(); |
| 233 | for (const child of Array.isArray(body?.children) ? body.children : []) { |
| 234 | if (typeof child?.path !== 'string' || child.path === '{}' || child.path.length === 0) { |
| 235 | continue; |
| 236 | } |
| 237 | if (child.kind === 'dir') { |
| 238 | dirs.add(child.path); |
| 239 | await graphFiles(port, child.path, seen, files, dirs); |
| 240 | } else if (!dirs.has(child.path)) { |
| 241 | files.add(child.path); |
| 242 | } |
| 243 | } |
| 244 | return { files, dirs }; |
| 245 | } |
| 246 | |
| 247 | /** Alle Scope-Seiten holen, bis der Server keine mehr meldet. */ |
| 248 | async function allScopeEntries(port) { |