Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web-backend): skip comment media when duplicating videos

Richie McIlroy0d8d4d6b13e1
diff --git a/packages/web-backend/src/Videos/index.ts b/packages/web-backend/src/Videos/index.ts
index 0564da427..2efc876e4 100644
--- a/packages/web-backend/src/Videos/index.ts
+++ b/packages/web-backend/src/Videos/index.ts
@@ -328,13 +328,19 @@ export class Videos extends Effect.Service<Videos>()("Videos", {
if (allObjects.Contents)
yield* Effect.all(
EffectArray.filterMap(allObjects.Contents, (obj) =>
- Option.map(Option.fromNullable(obj.Key), (key) => {
- const newKey = key.replace(prefix, newPrefix);
- return bucket.copyObject(
- `${bucket.bucketName}/${obj.Key}`,
- newKey,
- );
- }),
+ Option.fromNullable(obj.Key).pipe(
+ // Comment media belongs to the original video's comments,
+ // which aren't duplicated — copying the bytes would leave
+ // orphans no row points at.
+ Option.filter((key) => !key.includes("/comments/")),
+ Option.map((key) => {
+ const newKey = key.replace(prefix, newPrefix);
+ return bucket.copyObject(
+ `${bucket.bucketName}/${obj.Key}`,
+ newKey,
+ );
+ }),
+ ),
),
{ concurrency: 1 },
);