Google Drive uploads + unified Storage layer#1784
Merged
richiemcilroy merged 71 commits intomainfrom May 7, 2026
Merged
Conversation
Member
Author
|
hey @greptileai please rereview the PR |
Member
Author
|
hey @greptileai please re-review the PR big fella |
Member
Author
|
hey @greptileai please re-review the PR. |
Contributor
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change introduces optional Google Drive as a first-class recording/upload destination alongside existing S3-style storage, wired through a new Storage Effect service in @cap/web-backend that abstracts presigned PUT/POST, resumable Drive uploads, and per-video storageIntegrationId resolution.
Greptile Summary
This PR adds Google Drive as a first-class storage destination alongside S3, wired through a new
StorageEffect service in@cap/web-backend. The unified layer abstracts presigned PUT/POST, resumable Drive uploads, folder management, and per-videostorageIntegrationIdresolution through four new database migrations.Storage/GoogleDrive.ts,Storage/index.ts,Storage/StorageRepo.ts): implements Drive resumable upload sessions, folder reservation with DB-level optimistic locking, token caching with lease-based refresh coordination, and a proxy route (/api/storage/object) for serving Drive-hosted files.multipart.ts,signed.ts, and the desktop Rust client now resolve storage access per-video (Storage.getAccessForVideo) rather than per-user-bucket, propagating the provider type back to clients so Drive-specificContent-Rangeheaders are set correctly.schema.ts, migrations 0017–0020): addsstorage_integrationsandstorage_objectstables; FK constraints land in migration 0018 (not 0017).Confidence Score: 4/5
Broadly safe to merge; all previously flagged blocking issues are addressed and no new blocking defects were found.
The Drive storage layer is substantially more complete than the previous revision — token-refresh-on-every-call, thundering-herd DB polling, quota-cache credential-overwrite, and JSON.parse-throws paths are all addressed. No new blocking defects were found. The net risk is the sheer volume of new Drive-specific code and the interactions between DB-level reservation locking, in-process token cache, and resumable upload session lifecycle, all exercised in production for the first time.
The Drive folder-reservation path in packages/web-backend/src/Storage/GoogleDrive.ts and the sequential chunking logic in instant-mp4-uploader.ts are the most complex new paths and deserve close monitoring in production.
Important Files Changed
Comments Outside Diff (2)
apps/web/app/(org)/dashboard/caps/components/web-recorder-dialog/instant-mp4-uploader.ts, line 661-678 (link)finalTotalBytesis null when the last chunk is sentuploadBlobWithProgresssetsContent-Range: bytes N-M/*wheneverthis.finalTotalBytesis null. Google Drive's resumable upload protocol requires the final request to supply a concrete total; a request with total"*"always returns 308 Resume Incomplete and the file is never closed. If any finalisation path that doesn't setfinalTotalBytesflushes the remaining Drive buffer, the upload session stays open indefinitely andbucket.multipart.completethen callsgetGoogleDriveFileMetadataagainst a file Drive has not yet committed.Prompt To Fix With AI
apps/web/app/api/upload/[...route]/signed.ts, line 87-97 (link)The batch endpoint returns only
upload.url, droppingtypeandheaders. For Google Drive,upload.urlis a resumable-upload session URL. Any caller that PUTs to that URL withoutContent-Rangewill get an error — the header is mandatory for resumable uploads. The single-URL endpoint below correctly preservestypeandheaders; the batch path should do the same so callers can detect the Drive case and set the required header.Prompt To Fix With AI
Reviews (6): Last reviewed commit: "fix(web): map storage proxy errors and h..." | Re-trigger Greptile