fix(macOS): git date cache race and stale keys on vault open#243
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(macOS): git date cache race and stale keys on vault open#243cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Call setupGit before refreshAllFiles so the file scan's refreshGitDateCache sees gitService. Invalidate generation and clear cache when switching vaults to drop stale paths. Add regression test for vault switch. Co-authored-by: Danny Peck <dannypeck@gmail.com>
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.
Bug and impact
Opening a git-backed vault could leave
gitDateCacheempty or stale. The Created/Modified date views and calendar activity could fall back to filesystem timestamps (wrong after clone) or briefly show keys from a previously opened vault when switching workspaces.Root cause
openFoldercalledrefreshAllFiles()beforesetupGit(for:). The scan completion runsrefreshGitDateCache()on the main queue whilegitServicewas still nil, so that call returned immediately and bumpedgitDateCacheGeneration. The subsequentsetupGitrefresh could then be discarded as stale when the scan’s secondrefreshGitDateCacheran with a higher generation, leaving an empty cache merged with[:](no-op merge). Switching vaults without clearing the cache could also retain URLs under the old root until a successful refresh.Fix
setupGitbeforerefreshAllFilesso the scan always sees a livegitService.gitDateCacheGenerationand cleargitDateCachebefore wiring git.refreshGitDateCache()fromsetupGit(the scan owns the initial population).Validation
test_openFolder_switchingVaults_clearsGitDateCacheBeforeRepopulatinginAppStateGitDateFilteringTests.xcodebuild testnot run in this Linux agent environment; CI exercises macOS tests onpush.