[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/store/RFC.md fully. Find features d... #78
3 changed files with 15 additions and 7 deletions
1
store.go
1
store.go
|
|
@ -156,6 +156,7 @@ func newStoreFromConfig(operation string, config StoreConfig) (*Store, error) {
|
|||
}
|
||||
|
||||
storeInstance.startBackgroundPurge()
|
||||
storeInstance.cleanUpOrphanedWorkspaces(defaultWorkspaceStateDirectory)
|
||||
return storeInstance, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
11
workspace.go
11
workspace.go
|
|
@ -159,6 +159,17 @@ func discoverOrphanWorkspacePaths(stateDirectory string) []string {
|
|||
return orphanPaths
|
||||
}
|
||||
|
||||
func (storeInstance *Store) cleanUpOrphanedWorkspaces(stateDirectory string) {
|
||||
if storeInstance == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, orphanWorkspace := range storeInstance.RecoverOrphans(stateDirectory) {
|
||||
_ = orphanWorkspace.Aggregate()
|
||||
orphanWorkspace.Discard()
|
||||
}
|
||||
}
|
||||
|
||||
func workspaceNameFromPath(stateDirectory, databasePath string) string {
|
||||
relativePath := core.TrimPrefix(databasePath, joinPath(stateDirectory, ""))
|
||||
return core.TrimSuffix(relativePath, ".duckdb")
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ func TestWorkspace_RecoverOrphans_Good(t *testing.T) {
|
|||
assert.False(t, testFilesystem().Exists(workspaceFilePath(stateDirectory, "orphan-session")))
|
||||
}
|
||||
|
||||
func TestWorkspace_New_Good_PreservesOrphanedWorkspacesUntilRecovered(t *testing.T) {
|
||||
func TestWorkspace_New_Good_CleansUpOrphanedWorkspaces(t *testing.T) {
|
||||
stateDirectory := useWorkspaceStateDirectory(t)
|
||||
requireCoreOK(t, testFilesystem().EnsureDir(stateDirectory))
|
||||
|
||||
|
|
@ -198,11 +198,7 @@ func TestWorkspace_New_Good_PreservesOrphanedWorkspacesUntilRecovered(t *testing
|
|||
require.NoError(t, err)
|
||||
defer storeInstance.Close()
|
||||
|
||||
assert.True(t, testFilesystem().Exists(orphanDatabasePath))
|
||||
|
||||
orphans := storeInstance.RecoverOrphans(stateDirectory)
|
||||
require.Len(t, orphans, 1)
|
||||
orphans[0].Discard()
|
||||
|
||||
assert.False(t, testFilesystem().Exists(orphanDatabasePath))
|
||||
assert.False(t, testFilesystem().Exists(orphanDatabasePath+"-wal"))
|
||||
assert.False(t, testFilesystem().Exists(orphanDatabasePath+"-shm"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue