feat (refactor): Migrate Git sync to use SQLite-backed LocalDataStore with async operations and refactor related controllers and tests. - #18
Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (32)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change introduces SQLite-backed ChangesLocal persistence migration
Priority: ⬇️ Low Estimated code review effort: 5 (Critical) | ~90 minutes Change: Refactor Sequence Diagram(s)sequenceDiagram
participant macgitApp
participant LocalDataLoadingView
participant LocalDataStore
participant LocalSQLiteDatabase
macgitApp->>LocalDataLoadingView: Render application content
LocalDataLoadingView->>LocalDataStore: prepare()
LocalDataStore->>LocalSQLiteDatabase: Import legacy data and load records
LocalSQLiteDatabase-->>LocalDataStore: Return local records or error
LocalDataStore-->>LocalDataLoadingView: Publish ready or unavailable state
LocalDataLoadingView-->>macgitApp: Render content or retryable error
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Pull request title
Refactor Git‑Flow sync to use a persistent
LocalDataStoreand async operationsSummary
This branch replaces the in‑memory
UserDefaults‑based pending‑upload tracking used by the Git‑Flow sync logic with a robust, file‑backedLocalDataStorebacked by SQLite. The sync workflow is now fully asynchronous and serialised per repository to avoid race conditions between downloads and saves.Key changes
GitFlowConfigurationSyncControllerdataStore: LocalDataStorefor persistence.operationsmap to serialize async tasks per repository URL.serialized(in:operation:)helper that:dataStorebefore each operation.reconcileandsaveto use the new serializer.pendingUploadsKey/UserDefaultswithLocalDataStore:pendingVersion(_:),markPendingUpload(_:),clearPendingUpload(_:version:).pendingVersioninstead of a simple boolean flag.New Services
LocalDataStore.swift,LocalDataError.swift,LocalDataTransaction.swift: core abstraction for transactional, file‑based data access.LegacyLocalDataMigration.swift: helper for migrating pre‑existing data.LocalSQLiteDatabase.swift: SQLite implementation ofLocalDataStore.Updated Controllers & Views
dataStore.LocalDataLoadingView).Tests
LocalDataMigrationTests.swiftandLocalDataStoreTestFixture.swiftto verify persistence and transaction semantics.LocalDataStoreand async API.Impact
All changes are confined to the Git‑Flow sync module and its supporting persistence layer. No public API of the application has been altered.
Summary by CodeRabbit