MCPcopy
hub / github.com/CapSoftware/Cap / retryVideoProcessing

Function retryVideoProcessing

apps/web/actions/video/retry-processing.ts:44–131  ·  view source on GitHub ↗
({
	videoId,
}: {
	videoId: Video.VideoId;
})

Source from the content-addressed store, hash-verified

42};
43
44export async function retryVideoProcessing({
45 videoId,
46}: {
47 videoId: Video.VideoId;
48}): Promise<{ success: boolean; status: VideoProcessingStartStatus }> {
49 const user = await getCurrentUser();
50 if (!user) throw new Error("Unauthorized");
51
52 const [video] = await db()
53 .select()
54 .from(videos)
55 .where(eq(videos.id, videoId));
56
57 if (!video) throw new Error("Video not found");
58 if (video.ownerId !== user.id) throw new Error("Unauthorized");
59
60 const [upload] = await db()
61 .select()
62 .from(videoUploads)
63 .where(eq(videoUploads.videoId, videoId));
64
65 if (!upload) throw new Error("No upload record found");
66 if (!upload.rawFileKey) throw new Error("No raw file key found for retry");
67
68 const [importedVideo] = await db()
69 .select({
70 source: importedVideos.source,
71 sourceId: importedVideos.sourceId,
72 })
73 .from(importedVideos)
74 .where(eq(importedVideos.id, videoId));
75
76 if (importedVideo?.source === "loom") {
77 if (upload.phase === "processing" && !shouldForceRetryProcessing(upload)) {
78 return { success: true, status: "already-processing" };
79 }
80
81 await db()
82 .update(videoUploads)
83 .set({
84 phase: "processing",
85 processingProgress: 0,
86 processingMessage: "Retrying Loom import...",
87 processingError: null,
88 rawFileKey: upload.rawFileKey,
89 updatedAt: new Date(),
90 })
91 .where(eq(videoUploads.videoId, videoId));
92
93 try {
94 await start(importLoomVideoWorkflow, [
95 {
96 videoId,
97 userId: user.id,
98 rawFileKey: upload.rawFileKey,
99 bucketId: video.bucket ?? null,
100 loomDownloadUrl: "",
101 loomVideoId: importedVideo.sourceId,

Callers 2

CapVideoPlayerFunction · 0.90
retryProcessingFunction · 0.90

Calls 6

dbFunction · 0.90
startFunction · 0.90
setVideoProcessingErrorFunction · 0.90
updateMethod · 0.80

Tested by

no test coverage detected