From c00bc0ca3c9da8f565df82d850198cdcbfc97dff Mon Sep 17 00:00:00 2001 From: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:51:00 +0100 Subject: [PATCH] fix: Skip processing if segments above 149 --- apps/web/app/api/upload/mux/create/route.ts | 23 +++++++++++++++++++++ packages/database/schema.ts | 1 + 2 files changed, 24 insertions(+) diff --git a/apps/web/app/api/upload/mux/create/route.ts b/apps/web/app/api/upload/mux/create/route.ts index 0a38ae0d..bea163b5 100644 --- a/apps/web/app/api/upload/mux/create/route.ts +++ b/apps/web/app/api/upload/mux/create/route.ts @@ -125,6 +125,29 @@ export async function GET(request: NextRequest) { const videoSegmentKeys = (videoSegments.Contents || []).map( (object) => `s3://${bucket}/${object.Key}` ); + + if (videoSegmentKeys.length > 149) { + await db + .update(videos) + .set({ skipProcessing: true }) + .where(eq(videos.id, videoId)); + return new Response( + JSON.stringify({ + message: "Number of inputs exceeds limit, skipping processing", + }), + { + status: 200, + headers: { + "Access-Control-Allow-Origin": allowedOrigins.includes(origin) + ? origin + : "null", + "Access-Control-Allow-Credentials": "true", + "Access-Control-Allow-Methods": "GET, OPTIONS", + }, + } + ); + } + const audioSegmentKeys = (audioSegments.Contents || []).map( (object) => `s3://${bucket}/${object.Key}` ); diff --git a/packages/database/schema.ts b/packages/database/schema.ts index 1aab7617..9024c117 100644 --- a/packages/database/schema.ts +++ b/packages/database/schema.ts @@ -150,6 +150,7 @@ export const videos = mysqlTable( xStreamInfo: text("xStreamInfo"), jobId: varchar("jobId", { length: 255 }), jobStatus: varchar("jobStatus", { length: 255 }), + skipProcessing: boolean("skipProcessing").notNull().default(false), createdAt: timestamp("createdAt").notNull().defaultNow(), updatedAt: timestamp("updatedAt").notNull().defaultNow().onUpdateNow(), },