(path: string, name: string)
| 238 | const { expandedFolders } = get(); |
| 239 | |
| 240 | const buildNode = async (path: string, name: string): Promise<FolderNode> => { |
| 241 | const node: FolderNode = { |
| 242 | name, |
| 243 | path, |
| 244 | children: [], |
| 245 | isExpanded: expandedFolders.has(path) |
| 246 | }; |
| 247 | |
| 248 | try { |
| 249 | const entries = await TauriAPI.listDirectory(path); |
| 250 | const folders = entries |
| 251 | .filter((e: DirectoryEntry) => e.is_dir && !e.name.startsWith('.')) |
| 252 | .sort((a: DirectoryEntry, b: DirectoryEntry) => a.name.localeCompare(b.name)); |
| 253 | |
| 254 | for (const folder of folders) { |
| 255 | if (expandedFolders.has(path)) { |
| 256 | node.children.push(await buildNode(folder.path, folder.name)); |
| 257 | } else { |
| 258 | node.children.push({ |
| 259 | name: folder.name, |
| 260 | path: folder.path, |
| 261 | children: [], |
| 262 | isExpanded: false |
| 263 | }); |
| 264 | } |
| 265 | } |
| 266 | } catch (error) { |
| 267 | console.error('Failed to build folder tree:', error); |
| 268 | } |
| 269 | |
| 270 | return node; |
| 271 | }; |
| 272 | |
| 273 | const tree = await buildNode(rootPath, 'All'); |
| 274 | set({ folderTree: tree }); |
no test coverage detected