(forceRefresh = false)
| 125 | } |
| 126 | |
| 127 | export async function listBatchFiles(forceRefresh = false): Promise<BatchInfo[]> { |
| 128 | const now = Date.now() |
| 129 | |
| 130 | // Check cache |
| 131 | if (!forceRefresh && fileListCache && fileListCache.expires > now) { |
| 132 | return parseBatchInfos(fileListCache.data) |
| 133 | } |
| 134 | |
| 135 | // Fetch both directories in parallel |
| 136 | const [metaFiles, dataFiles] = await Promise.all([ |
| 137 | fetchFileList('metadata'), |
| 138 | fetchFileList('dataset'), |
| 139 | ]) |
| 140 | |
| 141 | const allFiles = [ |
| 142 | ...metaFiles.map(f => ({ ...f, path: f.path || `metadata/${f.path}` })), |
| 143 | ...dataFiles.map(f => ({ ...f, path: f.path || `dataset/${f.path}` })), |
| 144 | ] |
| 145 | |
| 146 | // Cache the combined list |
| 147 | fileListCache = { data: allFiles, expires: now + FILE_LIST_TTL } |
| 148 | |
| 149 | return parseBatchInfos(allFiles) |
| 150 | } |
| 151 | |
| 152 | function parseBatchInfos(files: HFFileEntry[]): BatchInfo[] { |
| 153 | return files |
no test coverage detected