fix: Check for custom-defined cache when migrating.

This commit is contained in:
Hayden Young 2023-01-05 16:59:44 +00:00
parent e6e3bcc994
commit cb21894828
3 changed files with 4 additions and 15 deletions

11
package-lock.json generated
View File

@ -12609,12 +12609,6 @@
"minimatch": "^3.0.4"
}
},
"node_modules/immediate": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz",
"integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==",
"extraneous": true
},
"node_modules/import-fresh": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
@ -39893,11 +39887,6 @@
"minimatch": "^3.0.4"
}
},
"immediate": {
"version": "https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz",
"integrity": "sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==",
"extraneous": true
},
"import-fresh": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",

View File

@ -6,7 +6,7 @@ const logger = Logger.create('orbit-db')
Logger.setLogLevel('ERROR')
export default async function migrate (OrbitDB, options, dbAddress) {
let oldCache = OrbitDB.caches[options.directory] ? OrbitDB.caches[options.directory].cache : null
let oldCache = options.cache || (OrbitDB.caches[options.directory] ? OrbitDB.caches[options.directory].cache : null)
let oldStore
if (!oldCache) {

View File

@ -152,7 +152,7 @@ Object.keys(testAPIs).forEach(API => {
await db2.close()
})
it.skip('loads cache from previous version of orbit-db', async () => {
it('loads cache from previous version of orbit-db', async () => {
const dbName = 'cache-schema-test'
db = await orbitdb.create(dbName, 'keyvalue', { overwrite: true })
@ -164,14 +164,14 @@ Object.keys(testAPIs).forEach(API => {
await db.drop()
await fs.copy(migrationFixturePath, migrationDataPath, { filter: filterFunc })
db = await orbitdb.create(dbName, 'keyvalue')
db = await orbitdb.create(dbName, 'keyvalue', { directory: migrationDataPath, overwrite: true })
await db.load()
assert.equal(manifestHash, db.address.root)
assert.equal((await db.get('key')), 'value')
})
it.skip('loads cache from previous version of orbit-db with the directory option', async () => {
it('loads cache from previous version of orbit-db with the directory option', async () => {
const dbName = 'cache-schema-test'
const directory = path.join(dbPath, "some-other-place")