diff options
| author | diogo464 <[email protected]> | 2025-08-11 16:10:17 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-11 16:10:17 +0100 |
| commit | 8bba15d57502e97b1b96590bd21e0e8f541eaac5 (patch) | |
| tree | 22c040d3251a8a5a9d6f9fb8888ba28a0887f18b /frontend | |
| parent | f4d8a26972728891de8bde4eeb94c80f027ce2d2 (diff) | |
add api route for recursive file listing
- Added /api/list route that returns all files/directories recursively from root
- Increased maxBuffer to 50MB in Drive_ls to handle large directory listings
- Fixes ENOBUFS error when listing entire drive contents
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/app/api/list/route.ts | 13 | ||||
| -rw-r--r-- | frontend/lib/drive_server.ts | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/frontend/app/api/list/route.ts b/frontend/app/api/list/route.ts new file mode 100644 index 0000000..425e89c --- /dev/null +++ b/frontend/app/api/list/route.ts | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | import { NextResponse } from 'next/server' | ||
| 2 | import { Drive_ls } from '@/lib/drive_server' | ||
| 3 | |||
| 4 | export async function GET() { | ||
| 5 | try { | ||
| 6 | const entries = await Drive_ls('/', true) | ||
| 7 | |||
| 8 | return NextResponse.json(entries) | ||
| 9 | } catch (error) { | ||
| 10 | console.error('Error listing files:', error) | ||
| 11 | throw error | ||
| 12 | } | ||
| 13 | } \ No newline at end of file | ||
diff --git a/frontend/lib/drive_server.ts b/frontend/lib/drive_server.ts index e682497..91c3cb4 100644 --- a/frontend/lib/drive_server.ts +++ b/frontend/lib/drive_server.ts | |||
| @@ -15,7 +15,7 @@ export async function Drive_ls(path: string, recursive: boolean): Promise<DriveL | |||
| 15 | args.push(path) | 15 | args.push(path) |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | const result = spawnSync('fctdrive', args, { encoding: 'utf-8' }) | 18 | const result = spawnSync('fctdrive', args, { encoding: 'utf-8', maxBuffer: 50 * 1024 * 1024 }) |
| 19 | if (result.error) { | 19 | if (result.error) { |
| 20 | throw new Error(`Failed to execute fctdrive: ${result.error.message}`) | 20 | throw new Error(`Failed to execute fctdrive: ${result.error.message}`) |
| 21 | } | 21 | } |
