mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
fix: pass path to migration.
This commit is contained in:
parent
d06d800943
commit
51ab079153
40
package-lock.json
generated
40
package-lock.json
generated
@ -46,7 +46,7 @@
|
||||
"go-ipfs": "^0.9.1",
|
||||
"ipfs": "^0.59.0",
|
||||
"ipfsd-ctl": "^10.0.3",
|
||||
"localstorage-level-migration": "~0.1.0",
|
||||
"localstorage-level-migration": "github:haydenyoung/localstorage-level-migration#esm",
|
||||
"markdown-toc": "^1.2.0",
|
||||
"mkdirp": "^1.0.4",
|
||||
"mocha": "^9.1.3",
|
||||
@ -16162,12 +16162,14 @@
|
||||
},
|
||||
"node_modules/localstorage-level-migration": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/localstorage-level-migration/-/localstorage-level-migration-0.1.0.tgz",
|
||||
"integrity": "sha512-T/FsTw6oDXOD4HZiA+H6IRsZm1laN4C9yYuWYMJeKrpBr0VrcFGRd/kJqf1/DxjNo7Xfp68xmSWEdh6aIt1BqQ==",
|
||||
"resolved": "git+ssh://git@github.com/haydenyoung/localstorage-level-migration.git#a02a62c2c5e70aaee9b3b8d523be64e3e931cfb8",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"level": "^5.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"level-js": "^6.1.0",
|
||||
"levelup": "^5.1.1",
|
||||
"mkdirp": "^1.0.4",
|
||||
"node-localstorage": "^1.3.1"
|
||||
}
|
||||
},
|
||||
@ -16416,18 +16418,6 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/localstorage-level-migration/node_modules/mkdirp": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.6"
|
||||
},
|
||||
"bin": {
|
||||
"mkdirp": "bin/cmd.js"
|
||||
}
|
||||
},
|
||||
"node_modules/localstorage-level-migration/node_modules/node-gyp-build": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.1.1.tgz",
|
||||
@ -42788,13 +42778,14 @@
|
||||
}
|
||||
},
|
||||
"localstorage-level-migration": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/localstorage-level-migration/-/localstorage-level-migration-0.1.0.tgz",
|
||||
"integrity": "sha512-T/FsTw6oDXOD4HZiA+H6IRsZm1laN4C9yYuWYMJeKrpBr0VrcFGRd/kJqf1/DxjNo7Xfp68xmSWEdh6aIt1BqQ==",
|
||||
"version": "git+ssh://git@github.com/haydenyoung/localstorage-level-migration.git#a02a62c2c5e70aaee9b3b8d523be64e3e931cfb8",
|
||||
"dev": true,
|
||||
"from": "localstorage-level-migration@github:haydenyoung/localstorage-level-migration#esm",
|
||||
"requires": {
|
||||
"level": "^5.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"level-js": "^6.1.0",
|
||||
"levelup": "^5.1.1",
|
||||
"mkdirp": "^1.0.4",
|
||||
"node-localstorage": "^1.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -42988,15 +42979,6 @@
|
||||
"xtend": "~4.0.0"
|
||||
}
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "^1.2.6"
|
||||
}
|
||||
},
|
||||
"node-gyp-build": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.1.1.tgz",
|
||||
|
@ -55,7 +55,7 @@
|
||||
"go-ipfs": "^0.9.1",
|
||||
"ipfs": "^0.59.0",
|
||||
"ipfsd-ctl": "^10.0.3",
|
||||
"localstorage-level-migration": "~0.1.0",
|
||||
"localstorage-level-migration": "github:haydenyoung/localstorage-level-migration#esm",
|
||||
"markdown-toc": "^1.2.0",
|
||||
"mkdirp": "^1.0.4",
|
||||
"mocha": "^9.1.3",
|
||||
|
@ -9,7 +9,7 @@ import Pubsub from 'orbit-db-pubsub'
|
||||
import Cache from 'orbit-db-cache'
|
||||
import Keystore from 'orbit-db-keystore'
|
||||
import Identities from 'orbit-db-identity-provider'
|
||||
import AccessControllers from 'orbit-db-access-controllers'
|
||||
import DefaultAccessControllers from 'orbit-db-access-controllers'
|
||||
import OrbitDBAddress from './orbit-db-address.js'
|
||||
import createDBManifest from './db-manifest.js'
|
||||
import exchangeHeads from './exchange-heads.js'
|
||||
@ -31,6 +31,7 @@ const databaseTypes = {
|
||||
}
|
||||
|
||||
const defaultTimeout = 30000 // 30 seconds
|
||||
let AccessControllers = DefaultAccessControllers
|
||||
|
||||
export default class OrbitDB {
|
||||
constructor (ipfs, identity, options = {}) {
|
||||
@ -43,8 +44,8 @@ export default class OrbitDB {
|
||||
this.id = options.peerId
|
||||
this._pubsub = !options.offline
|
||||
? new (
|
||||
options.broker ? options.broker : Pubsub
|
||||
)(this._ipfs, this.id)
|
||||
options.broker ? options.broker : Pubsub
|
||||
)(this._ipfs, this.id)
|
||||
: null
|
||||
this.directory = options.directory || './orbitdb'
|
||||
this.storage = options.storage
|
||||
@ -111,7 +112,7 @@ export default class OrbitDB {
|
||||
|
||||
if (!options.identity) {
|
||||
options.identity = await Identities.createIdentity({
|
||||
id: id,
|
||||
id,
|
||||
keystore: options.keystore
|
||||
})
|
||||
}
|
||||
@ -224,7 +225,7 @@ export default class OrbitDB {
|
||||
}
|
||||
|
||||
const opts = Object.assign({ replicate: true }, options, {
|
||||
accessController: accessController,
|
||||
accessController,
|
||||
cache: options.cache,
|
||||
onClose: this._onClose.bind(this),
|
||||
onDrop: this._onDrop.bind(this),
|
||||
@ -332,7 +333,7 @@ export default class OrbitDB {
|
||||
if (OrbitDBAddress.isValid(name)) { throw new Error('Given database name is an address. Please give only the name of the database!') }
|
||||
|
||||
// Create an AccessController, use IPFS AC as the default
|
||||
options.accessController = Object.assign({}, { name: name, type: 'ipfs' }, options.accessController)
|
||||
options.accessController = Object.assign({}, { name, type: 'ipfs' }, options.accessController)
|
||||
const accessControllerAddress = await AccessControllers.create(this, options.accessController.type, options.accessController || {})
|
||||
|
||||
// Save the manifest to IPFS
|
||||
@ -365,7 +366,7 @@ export default class OrbitDB {
|
||||
|
||||
if (haveDB && !options.overwrite) { throw new Error(`Database '${dbAddress}' already exists!`) }
|
||||
|
||||
await this._migrate(options, dbAddress)
|
||||
await this._migrate({ ...options, ...{ directory: this.directory } }, dbAddress)
|
||||
|
||||
// Save the database locally
|
||||
await this._addManifestToCache(options.cache, dbAddress)
|
||||
|
@ -4,8 +4,8 @@ import * as io from 'orbit-db-io'
|
||||
// Creates a DB manifest file and saves it in IPFS
|
||||
export default async (ipfs, name, type, accessControllerAddress, options) => {
|
||||
const manifest = Object.assign({
|
||||
name: name,
|
||||
type: type,
|
||||
name,
|
||||
type,
|
||||
accessController: (path.posix || path).join('/ipfs', accessControllerAddress)
|
||||
},
|
||||
// meta field is only added to manifest if options.meta is defined
|
||||
|
@ -38,7 +38,7 @@ export default async (ipfs, address, peer, getStore, getDirectConnection, onMess
|
||||
const heads = await getHeadsForDatabase(getStore(address))
|
||||
logger.debug(`Send latest heads of '${address}':\n`, JSON.stringify(heads.map(e => e.hash), null, 2))
|
||||
if (heads) {
|
||||
await channel.send(JSON.stringify({ address: address, heads: heads }))
|
||||
await channel.send(JSON.stringify({ address, heads }))
|
||||
}
|
||||
|
||||
return channel
|
||||
|
@ -122,7 +122,7 @@ Object.keys(testAPIs).forEach(API => {
|
||||
} catch (e) {
|
||||
err = e.toString()
|
||||
}
|
||||
assert.strictEqual(err, 'Error: Given AccessController class needs to implement: static get type() { /* return a string /}.')
|
||||
assert.strictEqual(err, 'Error: Given AccessController class needs to implement: static get type() { /* return a string */}.')
|
||||
})
|
||||
|
||||
it('creates a custom access controller', async () => {
|
||||
|
@ -110,7 +110,7 @@ Object.keys(testAPIs).forEach(API => {
|
||||
await accessController.load()
|
||||
})
|
||||
|
||||
it.only('creates an access controller', () => {
|
||||
it('creates an access controller', () => {
|
||||
assert.notStrictEqual(accessController, null)
|
||||
assert.notStrictEqual(accessController, undefined)
|
||||
})
|
||||
|
@ -1,4 +1,4 @@
|
||||
import IPFSFactory from 'ipfsd-ctl'
|
||||
import * as IPFSFactory from 'ipfsd-ctl'
|
||||
import { testAPIs } from './test-apis.js'
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
import assert from 'assert'
|
||||
import OrbitDB from '../src/OrbitDB.js'
|
||||
|
||||
const AccessController = OrbitDB.AccessController
|
||||
const AccessControllers = OrbitDB.AccessControllers
|
||||
const Identities = OrbitDB.Identities
|
||||
const Keystore = OrbitDB.Keystore
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user