feat(Git Sync): Persist insomnia git file hashes in workspace metadata#9873
feat(Git Sync): Persist insomnia git file hashes in workspace metadata#9873gatzjames wants to merge 1 commit intoKong:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent unnecessary workspace re-imports after app restarts by persisting git-sync tracking state (file hash + last sync time) into workspace metadata.
Changes:
- Persist
gitFileLastSyncHashandgitFileLastSyncTimetoWorkspaceMetaduring DB→FS flushes and FS→DB imports. - Restore persisted mtime/hash into the watcher’s in-memory tracking maps during startup to allow skipping unchanged files.
- Extend
WorkspaceMetamodel defaults/types to include the new persisted hash field.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/insomnia/src/sync/git/repo-file-watcher.ts | Persists and restores per-workspace git file hash/mtime to reduce redundant imports across restarts. |
| packages/insomnia/src/insomnia-data/src/models/workspace-meta.ts | Adds gitFileLastSyncHash to the workspace meta model and initialization defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Persist tracking state so the maps can be restored after a restart | ||
| const workspaceMeta = meta ?? (await services.workspaceMeta.getOrCreateByParentId(workspace._id)); | ||
| await services.workspaceMeta.update(workspaceMeta, { |
There was a problem hiding this comment.
gitFileLastSyncHash/gitFileLastSyncTime are persisted here, but gitFilePath is not. If meta.gitFilePath is null/undefined (which can happen for DB-created workspaces before any FS→DB import), loadKnownGitFilePaths() will ignore this meta record and the persisted hash/time won’t be restored on restart. Consider persisting gitFilePath (e.g. the computed default/rel path) when it’s missing, or adjusting the restore logic to fall back to the default filename when gitFilePath is null.
| // Persist tracking state so the maps can be restored after a restart | |
| const workspaceMeta = meta ?? (await services.workspaceMeta.getOrCreateByParentId(workspace._id)); | |
| await services.workspaceMeta.update(workspaceMeta, { | |
| // Persist tracking state so the maps can be restored after a restart. | |
| // Store the resolved gitFilePath as well so workspaces that previously | |
| // had no explicit meta.gitFilePath can restore their last sync state. | |
| const workspaceMeta = meta ?? (await services.workspaceMeta.getOrCreateByParentId(workspace._id)); | |
| await services.workspaceMeta.update(workspaceMeta, { | |
| gitFilePath, |
85de117 to
697da9d
Compare
Co-authored-by: Copilot <copilot@github.com>
697da9d to
2b8dd60
Compare
Overview
Currently we only store synced times in the metadata which leads to some files being re-imported while their contents are still the same.
This PR persists the hash to the workspace metadata alongside the sync time so that app restarts won't trigger re-imports if the file hashes are the same.