Download src/app/api/offcloud/scan/route.ts from Zero124/VR-MEDIA: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/src/app/api/offcloud/scan/route.ts
- Command line
-
hf download hf://spaces/Zero124/VR-MEDIA/src/app/api/offcloud/scan/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/src/app/api/offcloud/scan/route.ts
1.45 kB
| // POST /api/offcloud/scan — reconcile the library with Offcloud. | |
| // | |
| // This is now an INCREMENTAL sync: videos that are already indexed and ready to | |
| // play are never re-analyzed, only new Offcloud content is queued, and items | |
| // deleted from Offcloud are hidden. Add ?force=1 to re-analyze everything. | |
| // | |
| // The same sync also runs automatically every few seconds and on every boot, so | |
| // pressing this is only ever an impatience button. | |
| import { NextRequest, NextResponse } from "next/server"; | |
| import { syncOnce } from "@/lib/sync-engine"; | |
| export const dynamic = "force-dynamic"; | |
| export const runtime = "nodejs"; | |
| export async function POST(req: NextRequest) { | |
| try { | |
| const force = new URL(req.url).searchParams.get("force") === "1"; | |
| const result = await syncOnce({ | |
| mode: "full", | |
| trigger: force ? "force" : "manual", | |
| force, | |
| }); | |
| return NextResponse.json({ | |
| started: !result.error, | |
| // Back-compat field for older clients. | |
| queuedCount: result.requeued, | |
| added: result.added, | |
| skippedReady: result.skippedReady, | |
| markedMissing: result.markedMissing, | |
| pruned: result.pruned, | |
| discovered: result.discovered, | |
| mode: result.offcloudMode, | |
| error: result.error, | |
| }); | |
| } catch (err) { | |
| const msg = err instanceof Error ? err.message : "Unknown error"; | |
| return NextResponse.json({ error: msg }, { status: 500 }); | |
| } | |
| } | |