Skip to content

Commit 752d72c

Browse files
committed
more lint
1 parent bac2211 commit 752d72c

2 files changed

Lines changed: 34 additions & 21 deletions

File tree

apps/sim/ee/workspace-forking/lib/copy/copy-files.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ function isMarkdownBlob(task: Pick<BlobCopyTask, 'contentType' | 'fileName'>): b
3636
}
3737

3838
export interface BlobCopyTask {
39-
sourceFileId: string
40-
sourceContentUpdatedAtMs: number
39+
/** Added after persisted fork jobs shipped; absence marks only copied-file provenance unknown. */
40+
sourceFileId?: string
41+
/** Added after persisted fork jobs shipped; absence marks only copied-file provenance unknown. */
42+
sourceContentUpdatedAtMs?: number
4143
sourceKey: string
4244
targetKey: string
4345
context: StorageContext
@@ -324,11 +326,15 @@ export async function executeForkFileBlobCopies(
324326
}
325327
await copyWorkspaceFileSecretProvenanceInTx(
326328
tx,
327-
{
328-
fileId: task.sourceFileId,
329-
key: task.sourceKey,
330-
contentUpdatedAtMs: task.sourceContentUpdatedAtMs,
331-
},
329+
typeof task.sourceFileId === 'string' &&
330+
typeof task.sourceContentUpdatedAtMs === 'number' &&
331+
Number.isFinite(task.sourceContentUpdatedAtMs)
332+
? {
333+
fileId: task.sourceFileId,
334+
key: task.sourceKey,
335+
contentUpdatedAtMs: task.sourceContentUpdatedAtMs,
336+
}
337+
: undefined,
332338
task.targetFileId
333339
)
334340
await incrementStorageUsageForBillingContextInTx(tx, billingContext, task.size)

apps/sim/lib/uploads/contexts/workspace/workspace-file-secret-provenance.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,29 @@ export async function preserveWorkspaceFileSecretProvenanceInTx(
169169
/** Copies exact provenance for a byte-identical, same-owner-scope file copy; otherwise unknown. */
170170
export async function copyWorkspaceFileSecretProvenanceInTx(
171171
tx: DbOrTx,
172-
expectedSource: WorkspaceFileSecretProvenanceCopySource,
172+
expectedSource: WorkspaceFileSecretProvenanceCopySource | undefined,
173173
targetFileId: string
174174
): Promise<void> {
175+
const [target] = await tx
176+
.select({
177+
userId: workspaceFiles.userId,
178+
workspaceId: workspaceFiles.workspaceId,
179+
contentUpdatedAt: workspaceFiles.contentUpdatedAt,
180+
})
181+
.from(workspaceFiles)
182+
.where(eq(workspaceFiles.id, targetFileId))
183+
.limit(1)
184+
185+
if (!target) {
186+
throw new Error('Workspace file provenance copy could not bind the target file version')
187+
}
188+
if (!expectedSource) {
189+
await replaceWorkspaceFileSecretProvenanceInTx(tx, targetFileId, target.contentUpdatedAt, {
190+
status: 'unknown',
191+
})
192+
return
193+
}
194+
175195
const [source] = await tx
176196
.select({
177197
key: workspaceFiles.key,
@@ -189,19 +209,6 @@ export async function copyWorkspaceFileSecretProvenanceInTx(
189209
)
190210
.where(eq(workspaceFiles.id, expectedSource.fileId))
191211
.limit(1)
192-
const [target] = await tx
193-
.select({
194-
userId: workspaceFiles.userId,
195-
workspaceId: workspaceFiles.workspaceId,
196-
contentUpdatedAt: workspaceFiles.contentUpdatedAt,
197-
})
198-
.from(workspaceFiles)
199-
.where(eq(workspaceFiles.id, targetFileId))
200-
.limit(1)
201-
202-
if (!target) {
203-
throw new Error('Workspace file provenance copy could not bind the target file version')
204-
}
205212
if (
206213
!source ||
207214
source.key !== expectedSource.key ||

0 commit comments

Comments
 (0)