(dirPath: string)
| 33 | * Returns { files: [{ path, type, size }], not_exists: boolean } |
| 34 | */ |
| 35 | export async function listFiles(dirPath: string): Promise<{ |
| 36 | files: Array<{ path: string; type: number; size?: number }>; |
| 37 | not_exists: boolean; |
| 38 | }> { |
| 39 | try { |
| 40 | const res = await fetch(apiUrl(dirPath, 'list')); |
| 41 | if (res.ok) { |
| 42 | return await res.json(); |
| 43 | } |
| 44 | return { files: [], not_exists: true }; |
| 45 | } catch (e) { |
| 46 | console.warn('[diskStorage] listFiles failed:', e); |
| 47 | return { files: [], not_exists: true }; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Read a file. Returns parsed JSON (if JSON file) or string content, or null if not found. |
no test coverage detected