Skip to content

Commit 90982b0

Browse files
committed
fix: keep inspected missing uploads out of legacy recovery
1 parent ecc02f5 commit 90982b0

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

apps/web/__tests__/unit/desktop-segments-recovery.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ vi.mock("@cap/database/schema", () => ({
1717
phase: "upload.phase",
1818
updatedAt: "upload.updatedAt",
1919
startedAt: "upload.startedAt",
20+
processingError: "upload.processingError",
2021
},
2122
videoProcessingJobs: { videoId: "job.videoId" },
2223
}));
2324
vi.mock("drizzle-orm", () => ({
2425
and: (...args: unknown[]) => args,
26+
or: (...args: unknown[]) => ({ or: args }),
27+
notLike: (left: unknown, right: unknown) => ({ notLike: [left, right] }),
2528
asc: (value: unknown) => value,
2629
eq: (left: unknown, right: unknown) => ({ eq: [left, right] }),
2730
inArray: (left: unknown, right: unknown) => ({ in: [left, right] }),
@@ -51,6 +54,7 @@ vi.mock("@/lib/desktop-segments-finalization", () => ({
5154
}));
5255
vi.mock("@/lib/desktop-recording-jobs", () => ({
5356
listRecoverableSegmentJobs: mocks.recoverable,
57+
DESKTOP_RECORDING_SOURCE_REUPLOAD_REQUIRED: "source-reupload-required",
5458
SourceCommitPendingError: class SourceCommitPendingError extends Error {},
5559
DesktopRecordingSourceBlockedError: class DesktopRecordingSourceBlockedError extends Error {
5660
constructor(
@@ -234,6 +238,7 @@ describe("durable recovery scheduling", () => {
234238
expect(query).toContain('"processing"');
235239
expect(query).not.toContain("28 HOUR");
236240
expect(query).toContain("startedAt");
241+
expect(query).toContain("source-reupload-required:%");
237242
expect(mocks.put).not.toHaveBeenCalled();
238243
});
239244

apps/web/lib/desktop-segments-recovery.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@ import {
66
} from "@cap/database/schema";
77
import { Storage } from "@cap/web-backend";
88
import { type User, Video } from "@cap/web-domain";
9-
import { and, asc, eq, gte, inArray, isNull, lte, sql } from "drizzle-orm";
9+
import {
10+
and,
11+
asc,
12+
eq,
13+
gte,
14+
inArray,
15+
isNull,
16+
lte,
17+
notLike,
18+
or,
19+
sql,
20+
} from "drizzle-orm";
1021
import { Effect, Option, Schema } from "effect";
1122
import {
23+
DESKTOP_RECORDING_SOURCE_REUPLOAD_REQUIRED,
1224
DesktopRecordingSourceBlockedError,
1325
listRecoverableSegmentJobs,
1426
SourceCommitPendingError,
@@ -251,6 +263,13 @@ export async function recoverStaleDesktopSegments({
251263
new Date(now.getTime() - DESKTOP_SEGMENTS_LEGACY_RECOVERY_MAX_AGE_MS),
252264
),
253265
isNull(videoProcessingJobs.videoId),
266+
or(
267+
isNull(videoUploads.processingError),
268+
notLike(
269+
videoUploads.processingError,
270+
`${DESKTOP_RECORDING_SOURCE_REUPLOAD_REQUIRED}:%`,
271+
),
272+
),
254273
sql`JSON_UNQUOTE(JSON_EXTRACT(${videos.source}, '$.type')) = 'desktopSegments'`,
255274
),
256275
)

0 commit comments

Comments
 (0)