feat: Google native file export (RFC 0003)#72
Conversation
de0dc2b to
f78d2a0
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
f78d2a0 to
8faa747
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements RFC 0003 by adding support for exporting Google-native files (Docs, Sheets, Slides, etc.) during backup. Native files, which cannot be downloaded directly from Google Drive, are now exported to standard formats (e.g., .docx, .xlsx, .pptx) before content-addressed storage. Change detection uses headRevisionId instead of size/hash comparisons, which are unreliable for exported files.
Changes:
- New
gdrive_native.gowith MIME type detection, export format mapping, and extension helpers; integrated intoWalk,WalkChanges,toFileMeta, andGetFileStreamflows. - Change detection in
backup_scan.gousesheadRevisionId-based fast path for native files, carrying forward content metadata when unchanged. - CLI
--skip-native-filesflag to opt out of native file export for bothgdriveandgdrive-changessource types.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
rfcs/0003-google-native-file-export.md |
Status updated to Implemented; section renumbered |
pkg/source/gdrive_native.go |
New file: native MIME detection, export MIME/extension mapping |
pkg/source/gdrive_native_test.go |
Tests for native helper functions |
pkg/source/gdrive.go |
GDriveSource gains mimeTypes map, skipNativeFiles option, export routing in GetFileStream, native name/metadata handling in toFileMeta and visitEntryWithPath |
pkg/source/gdrive_changes.go |
WalkChanges initializes mimeTypes, adds headRevisionId to fields, skips native files when opted out, records MIME in changeToFileChange |
pkg/source/gdrive_test.go |
Comprehensive tests for toFileMeta, visitEntryWithPath, changeToFileChange, and option wiring |
internal/engine/backup_scan.go |
detectChange native fast-path using headRevisionId; new isGoogleNativeMeta helper |
internal/engine/backup_scan_test.go |
Tests for native change detection, empty revID, and metadata carry-forward |
cmd/cloudstic/cmd_backup.go |
--skip-native-files CLI flag; initSource updated for both gdrive source types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| // Record MIME type for GetFileStream export routing. | ||
| if ch.File.MimeType != "application/vnd.google-apps.folder" { |
Summary
Implement RFC 0003 by exporting Google-native files (Docs/Sheets/Slides/etc.) during backup so they are represented as real content in snapshots.
What Changes
Files of Interest
pkg/source/gdrive_native.gopkg/source/gdrive_native_test.gopkg/source/gdrive.gopkg/source/gdrive_changes.gointernal/engine/backup_scan.gointernal/engine/backup_scan_test.gopkg/source/gdrive_test.goBehavior Notes
Tracking
rfcs/0003-google-native-file-export.md