Skip to content

feat(proto): add backup and restore for proto preference#171

Merged
ArthurKun21 merged 3 commits into
masterfrom
feat/proto/backup-and-restore
Jun 27, 2026
Merged

feat(proto): add backup and restore for proto preference#171
ArthurKun21 merged 3 commits into
masterfrom
feat/proto/backup-and-restore

Conversation

@ArthurKun21

Copy link
Copy Markdown
Owner

New Pull Request

Pull Request Type

  • Chore/Refactor
  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

Description

Added a way to perform backup and restore by exporting the current proto datastore's file

Screenshots

Testing

Additional context

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces byte-array backup and restore capabilities (exportAsByteArray and importFromByteArray) to ProtoDatastore and GenericProtoDatastore, allowing factory-created datastores to export and import raw bytes. It includes multiplatform tests across Android, iOS, and Desktop, and integrates FileKit into the sample Compose applications to demonstrate the export and restore UI. The review feedback highlights a potential concurrency and file-locking issue on Windows/Desktop when reading the datastore file directly from the file system during backup. It suggests a safer, fully synchronized, in-memory serialization approach using the existing OkioSerializer instead of direct file system access.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@ArthurKun21

Copy link
Copy Markdown
Owner Author

/gemini summary

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

This pull request introduces robust backup and restore capabilities for ProtoDatastore, enabling users to export and import the datastore state as a byte array. By capturing the necessary serializer and file path information during datastore creation, the implementation provides a seamless way to persist or migrate data. The changes include new core APIs, specialized backup/restore utilities, extensive cross-platform testing, and a practical UI implementation in the sample application.

Highlights

  • New Backup/Restore APIs: Added exportAsByteArray and importFromByteArray methods to ProtoDatastore and GenericProtoDatastore to facilitate data persistence.
  • Backup Logic Implementation: Introduced ProtoBackupCreator and ProtoBackupRestorer to handle raw byte serialization and datastore updates.
  • Factory Updates: Updated createProtoDatastore to track the serializer and file path, enabling the new backup functionality.
  • Cross-Platform Testing: Added comprehensive unit tests covering Android, iOS, and Desktop platforms to ensure reliable backup and restore behavior.
  • Sample App Integration: Integrated FileKit into the sample application to provide a UI for testing the new backup and restore features.
Activity
  • The pull request was created by ArthurKun21.
  • A review comment was provided suggesting an alternative, safer implementation for exportAsByteArray to avoid potential file locking issues on desktop platforms.
  • The author requested a summary of the pull request.

@ArthurKun21 ArthurKun21 merged commit 75d8961 into master Jun 27, 2026
12 checks passed
@ArthurKun21 ArthurKun21 deleted the feat/proto/backup-and-restore branch June 27, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant