**fix(storage): ensure index clearing and statistics flushing for consistency**
- Updated `brainyData.ts`: - Made `this.index.clear()` asynchronous to prevent potential timing issues during storage test. - Added conditional `this.storage.flushStatisticsToStorage()` call to ensure statistics are properly flushed, avoiding data inconsistencies. **Purpose**: Enhance storage consistency by ensuring proper index clearing and statistics flushing during tests.
This commit is contained in:
parent
90eccd75aa
commit
d2c1dd14e1
1 changed files with 6 additions and 1 deletions
|
|
@ -4292,7 +4292,12 @@ export class BrainyData<T = any> implements BrainyDataInterface<T> {
|
|||
)
|
||||
|
||||
// Explicitly clear the index for the storage test
|
||||
this.index.clear()
|
||||
await this.index.clear()
|
||||
|
||||
// Ensure statistics are properly flushed to avoid inconsistencies
|
||||
if (this.storage) {
|
||||
await this.storage.flushStatisticsToStorage()
|
||||
}
|
||||
} else {
|
||||
// Re-add all nouns to the index for normal operation
|
||||
for (const noun of data.nouns) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue