Skip to content

Commit efa72b7

Browse files
committed
chore: upgrade to latest datastore-level
BREAKING CHANGE: requires repo migration to v10
1 parent b925ea3 commit efa72b7

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@
6060
"cids": "^1.0.0",
6161
"datastore-core": "^3.0.0",
6262
"datastore-fs": "^3.0.0",
63-
"datastore-level": "^3.0.0",
63+
"datastore-level": "ipfs/js-datastore-level#dependabot/npm_and_yarn/level-6.0.1",
6464
"debug": "^4.1.0",
6565
"err-code": "^2.0.0",
6666
"interface-datastore": "^3.0.3",
67-
"ipfs-repo-migrations": "^5.0.3",
67+
"ipfs-repo-migrations": "ipfs/js-ipfs-repo-migrations#feat/migration-10",
6868
"ipfs-utils": "^6.0.0",
6969
"ipld-block": "^0.11.0",
7070
"it-map": "^1.0.2",

src/config.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const errcode = require('err-code')
88
const errors = require('./errors')
99
const uint8ArrayToString = require('uint8arrays/to-string')
1010
const uint8ArrayFromString = require('uint8arrays/from-string')
11+
const {
12+
hasWithFallback,
13+
getWithFallback
14+
} = require('ipfs-repo-migrations/src/utils')
1115

1216
const configKey = new Key('config')
1317

@@ -39,7 +43,10 @@ module.exports = (store) => {
3943
key = undefined
4044
}
4145

42-
const encodedValue = await store.get(configKey)
46+
// [email protected] cannot read keys from [email protected] dbs so fall back to
47+
// using IndexedDB API with string keys - only necessary until we do
48+
// the migratiion to v10 or above
49+
const encodedValue = await getWithFallback(configKey, store.get.bind(store), store.has.bind(store), store)
4350

4451
if (options.signal && options.signal.aborted) {
4552
return
@@ -106,7 +113,10 @@ module.exports = (store) => {
106113
* @returns {Promise<bool>}
107114
*/
108115
async exists () { // eslint-disable-line require-await
109-
return store.has(configKey)
116+
// [email protected] cannot read keys from [email protected] dbs so fall back to
117+
// using IndexedDB API with string keys - only necessary until we do
118+
// the migratiion to v10 or above
119+
return hasWithFallback(configKey, store.has.bind(store), store)
110120
}
111121
}
112122

src/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
22

33
module.exports = {
4-
repoVersion: 9
4+
repoVersion: 10
55
}

src/version.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const debug = require('debug')
55
const log = debug('ipfs:repo:version')
66
const uint8ArrayToString = require('uint8arrays/to-string')
77
const uint8ArrayFromString = require('uint8arrays/from-string')
8+
const {
9+
hasWithFallback,
10+
getWithFallback
11+
} = require('ipfs-repo-migrations/src/utils')
812

913
const versionKey = new Key('version')
1014

@@ -16,15 +20,21 @@ module.exports = (store) => {
1620
* @returns {Promise<bool>}
1721
*/
1822
async exists () { // eslint-disable-line require-await
19-
return store.has(versionKey)
23+
// [email protected] cannot read keys from [email protected] dbs so fall back to
24+
// using IndexedDB API with string keys - only necessary until we do
25+
// the migratiion to v10 or above
26+
return hasWithFallback(versionKey, store.has.bind(store), store)
2027
},
2128
/**
2229
* Get the current version.
2330
*
2431
* @returns {Promise<Integer>}
2532
*/
2633
async get () {
27-
const buf = await store.get(versionKey)
34+
// [email protected] cannot read keys from [email protected] dbs so fall back to
35+
// using IndexedDB API with string keys - only necessary until we do
36+
// the migratiion to v10 or above
37+
const buf = await getWithFallback(versionKey, store.get.bind(store), store.has.bind(store), store)
2838
return parseInt(uint8ArrayToString(buf), 10)
2939
},
3040
/**

test/repo-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ module.exports = (repo) => {
5656

5757
describe('version', () => {
5858
afterEach(async () => {
59-
await repo.version.set(9)
59+
await repo.version.set(10)
6060
})
6161

6262
it('get version', async () => {
6363
const version = await repo.version.get()
64-
expect(version).to.equal(9)
64+
expect(version).to.equal(10)
6565
})
6666

6767
it('set version', async () => {

0 commit comments

Comments
 (0)