( key: string, previous: typeof Db.storageObjects.$inferSelect, )
| 348 | const getObjectRecord = (key: string) => |
| 349 | mapStorageError(requireDriveObject(repo, integrationId, key)); |
| 350 | const recoverDriveFileId = ( |
| 351 | key: string, |
| 352 | previous: typeof Db.storageObjects.$inferSelect, |
| 353 | ) => |
| 354 | findGoogleDriveFileByObjectKey(config, key, tokenStore).pipe( |
| 355 | Effect.flatMap( |
| 356 | Option.match({ |
| 357 | onNone: () => |
| 358 | Effect.fail( |
| 359 | new StorageDomain.StorageError({ |
| 360 | cause: new Error(`Google Drive object not found: ${key}`), |
| 361 | }), |
| 362 | ), |
| 363 | onSome: (file) => { |
| 364 | const videoId = parseObjectKeyVideoId(key); |
| 365 | const contentType = file.mimeType ?? previous.contentType; |
| 366 | return mapStorageError( |
| 367 | repo.upsertObject({ |
| 368 | integrationId, |
| 369 | ownerId, |
| 370 | videoId, |
| 371 | objectKey: key, |
| 372 | providerObjectId: file.id, |
| 373 | uploadStatus: "complete", |
| 374 | contentType, |
| 375 | contentLength: |
| 376 | parseGoogleDriveContentLength(file) ?? |
| 377 | previous.contentLength ?? |
| 378 | null, |
| 379 | metadata: { |
| 380 | ...(previous.metadata ?? {}), |
| 381 | videoId: videoId ?? previous.metadata?.videoId, |
| 382 | fileName: file.name ?? previous.metadata?.fileName, |
| 383 | contentType: file.mimeType ?? previous.metadata?.contentType, |
| 384 | }, |
| 385 | }), |
| 386 | ).pipe(Effect.as(file.id)); |
| 387 | }, |
| 388 | }), |
| 389 | ), |
| 390 | ); |
| 391 | const withRecoveredDriveFile = <A>( |
| 392 | key: string, |
| 393 | object: typeof Db.storageObjects.$inferSelect, |
no test coverage detected