fix: resolve clear() not deleting COW data and counters
Fixes critical bug where brain.clear() did not fully clear storage:
Root causes:
1. _cow/ directory contents deleted but directory not removed
2. In-memory counters (totalNounCount, totalVerbCount) not reset
3. COW could auto-reinitialize on next operation
Fixes applied:
- FileSystemStorage: Delete entire _cow/ directory with fs.rm()
- OPFSStorage: Delete _cow/ with removeEntry({recursive: true})
- S3CompatibleStorage: Reset counters after clear
- BaseStorage: Guard initializeCOW() against reinit when cowEnabled=false
- All adapters: Reset totalNounCount and totalVerbCount to 0
Impact: Resolves Workshop bug report - storage now properly clears from
103MB to 0 bytes, entity counts correctly return to 0.
GCSStorage, R2Storage, AzureBlobStorage already had correct implementations.
This commit is contained in:
parent
ef7bf1b04c
commit
e6cc12b64e
8 changed files with 141 additions and 4 deletions
|
|
@ -289,6 +289,12 @@ export abstract class BaseStorage extends BaseStorageAdapter {
|
|||
branch?: string
|
||||
enableCompression?: boolean
|
||||
}): Promise<void> {
|
||||
// v5.6.1: If COW was explicitly disabled (e.g., via clear()), don't reinitialize
|
||||
// This prevents automatic recreation of COW data after clear() operations
|
||||
if (this.cowEnabled === false) {
|
||||
return
|
||||
}
|
||||
|
||||
// Check if RefManager already initialized (full COW setup complete)
|
||||
if (this.refManager) {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue