MCPcopy Index your code
hub / github.com/CapSoftware/Cap / invalidateVideoCache

Function invalidateVideoCache

apps/web/actions/admin/replace-video.ts:64–98  ·  view source on GitHub ↗
(videoId: string)

Source from the content-addressed store, hash-verified

62}
63
64export async function invalidateVideoCache(videoId: string) {
65 await requireAdmin();
66 const video = await getVideoOrThrow(videoId);
67
68 if (video.bucket) {
69 return;
70 }
71
72 const distributionId = serverEnv().CAP_CLOUDFRONT_DISTRIBUTION_ID;
73 if (!distributionId) {
74 return;
75 }
76
77 const fileKey = `${video.ownerId}/${video.id}/result.mp4`;
78
79 const cloudfront = new CloudFrontClient({
80 region: serverEnv().CAP_AWS_REGION || "us-east-1",
81 credentials: await runPromise(
82 Effect.map(AwsCredentials, (c) => c.credentials),
83 ),
84 });
85
86 await cloudfront.send(
87 new CreateInvalidationCommand({
88 DistributionId: distributionId,
89 InvalidationBatch: {
90 CallerReference: `${Date.now()}`,
91 Paths: {
92 Quantity: 1,
93 Items: [`/${fileKey}`],
94 },
95 },
96 }),
97 );
98}

Callers 1

ReplaceVideoPanelFunction · 0.90

Calls 5

serverEnvFunction · 0.90
runPromiseFunction · 0.90
getVideoOrThrowFunction · 0.85
requireAdminFunction · 0.70
sendMethod · 0.45

Tested by

no test coverage detected