Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a bug in the restore function, which seems to cause the plugin to fail to initialize normally. #27

Open
ZDFX opened this issue Nov 3, 2024 · 1 comment

Comments

@ZDFX
Copy link

ZDFX commented Nov 3, 2024

// src/VectorStore.ts>OramaStore
    async restore(vectorStoreBackup: VectorStoreBackup) {
        Log.debug('Restoring vectorstore from backup');
        // vectorStoreBackup is an object and not an array for some reason
        const docs = Object.keys(vectorStoreBackup.docs).map((key) => vectorStoreBackup.docs[key]);
        await this.create(vectorStoreBackup.indexName, vectorStoreBackup.vectorSize);
        await insertMultiple(this.db, docs);// plugin:smart-second-brain:30 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'length')
        Log.info('Restored vectorstore from backup');
        Log.debug(this.db.data.docs.docs);
    }

Can I fix the error like this?

async restore(vectorStoreBackup: VectorStoreBackup) {
    Log.debug('Restoring vectorstore from backup');
    const docs = Object.keys(vectorStoreBackup.docs).map((key) => vectorStoreBackup.docs[key]);
    await this.create(vectorStoreBackup.indexName, vectorStoreBackup.vectorSize);
    
    if (docs.length > 0) {
        await insertMultiple(this.db, docs);
    } else {
        Log.info('No documents to restore');
    }
    
    Log.info('Restored vectorstore from backup');
    Log.debug(this.db.data.docs.docs);
}
@Leo310
Copy link
Member

Leo310 commented Nov 4, 2024

I will take a look at this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants