From 21cc6425bed202296cb1f1316a8fbbdb7137e822 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 13 Apr 2021 14:23:09 +0100 Subject: [PATCH 1/6] chore: run migration tests against s3-datastore Refactors tests to have one list of different repo configs, and to run all tests against all configs. This lets us test migrations against level, fs, s3, etc just by adding a new config to the list in `test/browser.js` and/or `test/node.js` --- migrations/migration-9/index.js | 1 - package.json | 7 +- src/index.js | 6 +- src/repo/lock.js | 9 +- test/browser.js | 88 +++++++------- test/fixtures/mock-s3.js | 84 ++++++++++++++ test/fixtures/repo.js | 12 +- test/integration-test.js | 7 +- test/migrations/index.js | 84 +------------- test/migrations/migration-9-test.js | 2 +- test/node.js | 170 +++++++++++++++++++++------- 11 files changed, 287 insertions(+), 183 deletions(-) create mode 100644 test/fixtures/mock-s3.js diff --git a/migrations/migration-9/index.js b/migrations/migration-9/index.js index cb7de7f..e42cf8a 100644 --- a/migrations/migration-9/index.js +++ b/migrations/migration-9/index.js @@ -2,7 +2,6 @@ const CID = require('cids') const dagpb = require('ipld-dag-pb') -// @ts-ignore https://github.com/rvagg/cborg/pull/5 const cbor = require('cborg') const multicodec = require('multicodec') const multibase = require('multibase') diff --git a/package.json b/package.json index 3e2575a..2eb611f 100644 --- a/package.json +++ b/package.json @@ -66,10 +66,12 @@ "@ipld/car": "^0.1.3", "@types/debug": "^4.1.5", "@types/varint": "^6.0.0", - "aegir": "^32.1.0", + "aegir": "^33.0.0", "assert": "^2.0.0", + "aws-sdk": "^2.884.0", "datastore-fs": "^3.0.0", "datastore-level": "^4.0.0", + "datastore-s3": "^4.0.0", "events": "^3.2.0", "it-all": "^1.0.2", "just-safe-set": "^2.1.0", @@ -79,7 +81,8 @@ "npm-run-all": "^4.1.5", "readable-stream": "^3.6.0", "rimraf": "^3.0.0", - "sinon": "^9.0.2", + "sinon": "^10.0.0", + "stand-in": "^4.2.0", "util": "^0.12.3" }, "engines": { diff --git a/src/index.js b/src/index.js index 753bd6d..0893bf6 100644 --- a/src/index.js +++ b/src/index.js @@ -85,7 +85,7 @@ async function migrate (path, repoOptions, toVersion, { ignoreLock = false, onPr let lock if (!isDryRun && !ignoreLock) { - lock = await repoLock.lock(currentVersion, path) + lock = await repoLock.lock(currentVersion, path, repoOptions) } try { @@ -185,7 +185,9 @@ async function revert (path, repoOptions, toVersion, { ignoreLock = false, onPro verifyAvailableMigrations(migrations, toVersion, currentVersion, true) let lock - if (!isDryRun && !ignoreLock) lock = await repoLock.lock(currentVersion, path) + if (!isDryRun && !ignoreLock) { + lock = await repoLock.lock(currentVersion, path, repoOptions) + } log(`Reverting from version ${currentVersion} to ${toVersion}`) diff --git a/src/repo/lock.js b/src/repo/lock.js index 9d96c4a..03574e9 100644 --- a/src/repo/lock.js +++ b/src/repo/lock.js @@ -3,6 +3,7 @@ const debug = require('debug') // @ts-ignore const { lock: properLock } = require('proper-lockfile') +const { lock: memoryLock } = require('./lock-memory') const log = debug('ipfs:repo:migrator:repo_fs_lock') const lockFile = 'repo.lock' @@ -12,8 +13,14 @@ const lockFile = 'repo.lock' * * @param {number} version * @param {string} dir + * @param {object} [repoOptions] + * @param {string} [repoOptions.lock] */ -async function lock (version, dir) { +async function lock (version, dir, repoOptions) { + if (repoOptions && repoOptions.lock === 'memory') { + return memoryLock(version, dir) + } + const file = `${dir}/${lockFile}` log('locking %s', file) const release = await properLock(dir, { lockfilePath: file }) diff --git a/test/browser.js b/test/browser.js index d149fce..8ef2004 100644 --- a/test/browser.js +++ b/test/browser.js @@ -2,40 +2,7 @@ 'use strict' const DatastoreLevel = require('datastore-level') -const { createRepo, createAndLoadRepo } = require('./fixtures/repo') - -const repoOptions = { - lock: 'memory', - storageBackends: { - root: DatastoreLevel, - blocks: DatastoreLevel, - keys: DatastoreLevel, - datastore: DatastoreLevel, - pins: DatastoreLevel - }, - storageBackendOptions: { - root: { - extension: '', - prefix: '', - version: 2 - }, - blocks: { - sharding: false, - prefix: '', - version: 2 - }, - keys: { - sharding: false, - prefix: '', - version: 2 - }, - datastore: { - sharding: false, - prefix: '', - version: 2 - } - } -} +const { createRepo } = require('./fixtures/repo') async function deleteDb (dir) { return new Promise((resolve) => { @@ -50,7 +17,7 @@ async function deleteDb (dir) { }) } -async function repoCleanup (dir) { +async function cleanup (dir) { await deleteDb(dir) await deleteDb('level-js-' + dir) @@ -60,26 +27,65 @@ async function repoCleanup (dir) { } } -describe('Browser specific tests', () => { +const CONFIGURATIONS = [{ + name: 'local', + cleanup, + repoOptions: { + lock: 'memory', + storageBackends: { + root: DatastoreLevel, + blocks: DatastoreLevel, + keys: DatastoreLevel, + datastore: DatastoreLevel, + pins: DatastoreLevel + }, + storageBackendOptions: { + root: { + extension: '', + prefix: '', + version: 2 + }, + blocks: { + sharding: false, + prefix: '', + version: 2 + }, + keys: { + sharding: false, + prefix: '', + version: 2 + }, + datastore: { + sharding: false, + prefix: '', + version: 2 + } + } + } +}] + +CONFIGURATIONS.forEach(({ name, repoOptions, cleanup }) => { + const setup = () => createRepo(repoOptions) + describe('lock.js tests', () => { describe('mem-lock tests', () => { - require('./lock-test')(require('../src/repo/lock-memory'), () => createRepo(repoOptions), repoCleanup, repoOptions) + require('./lock-test')(require('../src/repo/lock-memory'), setup, cleanup, repoOptions) }) }) describe('version tests', () => { - require('./version-test')(() => createRepo(repoOptions), repoCleanup, repoOptions) + require('./version-test')(setup, cleanup, repoOptions) }) describe('migrations tests', () => { - require('./migrations')(() => createRepo(repoOptions), repoCleanup) + require('./migrations')(setup, cleanup, repoOptions) }) describe('init tests', () => { - require('./init-test')(() => createRepo(repoOptions), repoCleanup, repoOptions) + require('./init-test')(setup, cleanup, repoOptions) }) describe('integration tests', () => { - require('./integration-test')(() => createAndLoadRepo(repoOptions), repoCleanup, repoOptions) + require('./integration-test')(setup, cleanup, repoOptions) }) }) diff --git a/test/fixtures/mock-s3.js b/test/fixtures/mock-s3.js new file mode 100644 index 0000000..d79adb7 --- /dev/null +++ b/test/fixtures/mock-s3.js @@ -0,0 +1,84 @@ +/* eslint-env mocha */ +'use strict' + +const chai = require('chai') +chai.use(require('dirty-chai')) +const expect = chai.expect +const standin = require('stand-in') +const { Buffer } = require('buffer') + +class S3Error extends Error { + constructor (message, code) { + super(message) + this.code = message + this.statusCode = code + } +} + +const s3Resolve = (res) => ({ promise: () => Promise.resolve(res) }) +const s3Reject = (err) => ({ promise: () => Promise.reject(err) }) + +/** + * Mocks out the s3 calls made by datastore-s3 + * + * @param {S3Instance} s3 + * @returns {void} + */ +module.exports = function (s3) { + const mocks = {} + const storage = {} + + mocks.deleteObject = standin.replace(s3, 'deleteObject', (stand, params) => { + expect(params.Key).to.be.a('string') + if (storage[params.Key]) { + delete storage[params.Key] + return s3Resolve({}) + } + return s3Reject(new S3Error('NotFound', 404)) + }) + + mocks.getObject = standin.replace(s3, 'getObject', (stand, params) => { + expect(params.Key).to.be.a('string') + if (storage[params.Key]) { + return s3Resolve({ Body: storage[params.Key] }) + } + return s3Reject(new S3Error('NotFound', 404)) + }) + + mocks.headBucket = standin.replace(s3, 'headBucket', (stand, params) => { + expect(params.Bucket).to.be.a('string') + return s3Resolve() + }) + + mocks.headObject = standin.replace(s3, 'headObject', (stand, params) => { + expect(params.Key).to.be.a('string') + if (storage[params.Key]) { + return s3Resolve({}) + } + return s3Reject(new S3Error('NotFound', 404)) + }) + + mocks.listObjectV2 = standin.replace(s3, 'listObjectsV2', (stand, params) => { + expect(params.Prefix).to.be.a('string') + const results = { + Contents: [] + } + + for (const k in storage) { + if (k.startsWith(params.Prefix)) { + results.Contents.push({ + Key: k + }) + } + } + + return s3Resolve(results) + }) + + mocks.upload = standin.replace(s3, 'upload', (stand, params) => { + expect(params.Key).to.be.a('string') + expect(params.Body).to.be.instanceof(Buffer) + storage[params.Key] = params.Body + return s3Resolve({}) + }) +} diff --git a/test/fixtures/repo.js b/test/fixtures/repo.js index b8d45f9..ab09346 100644 --- a/test/fixtures/repo.js +++ b/test/fixtures/repo.js @@ -4,23 +4,19 @@ const loadFixture = require('aegir/utils/fixtures') const { CONFIG_KEY, VERSION_KEY, createStore } = require('../../src/utils') async function createRepo (repoOptions, prefix) { - const date = Date.now().toString() - const dir = `${prefix ? `${prefix}/` : ''}test-repo-for-${date}` + const dir = `${prefix ? `${prefix}/` : ''}test-repo-for-${Date.now()}` const store = createStore(dir, 'root', repoOptions) await store.open() await store.close() + return dir } -async function createAndLoadRepo (repoOptions, prefix) { - const date = Date.now().toString() - const dir = `${prefix ? `${prefix}/` : ''}test-repo-for-${date}` +async function initRepo (dir, repoOptions) { const store = createStore(dir, 'root', repoOptions) await store.open() - await store.put(VERSION_KEY, loadFixture('test/fixtures/test-repo/version')) await store.put(CONFIG_KEY, loadFixture('test/fixtures/test-repo/config')) - await store.close() return dir @@ -28,5 +24,5 @@ async function createAndLoadRepo (repoOptions, prefix) { module.exports = { createRepo, - createAndLoadRepo + initRepo } diff --git a/test/integration-test.js b/test/integration-test.js index 20d5015..1c9d247 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -6,16 +6,17 @@ const { expect } = require('aegir/utils/chai') const migrator = require('../src') const migrations = require('./test-migrations') const { VERSION_KEY, CONFIG_KEY, createStore } = require('../src/utils') +const { initRepo } = require('./fixtures/repo') module.exports = (setup, cleanup, repoOptions) => { let dir beforeEach(async () => { dir = await setup() + await initRepo(dir, repoOptions) }) - afterEach(() => - cleanup(dir) - ) + + afterEach(() => cleanup(dir)) it('migrate forward', async () => { await migrator.migrate(dir, repoOptions, migrator.getLatestMigrationVersion(migrations), { diff --git a/test/migrations/index.js b/test/migrations/index.js index bdc4129..6e33442 100644 --- a/test/migrations/index.js +++ b/test/migrations/index.js @@ -1,83 +1,7 @@ -/* eslint-env mocha */ 'use strict' -const DatastoreFS = require('datastore-fs') -const DatastoreLevel = require('datastore-level') - -const CONFIGURATIONS = [{ - name: 'with sharding', - options: { - storageBackends: { - root: DatastoreFS, - blocks: DatastoreFS, - datastore: DatastoreLevel, - keys: DatastoreLevel, - pins: DatastoreLevel - }, - storageBackendOptions: { - root: { - sharding: true, - extension: '' - }, - blocks: { - sharding: true, - extension: '.data' - }, - datastore: { - sharding: true, - extension: '.data' - }, - keys: { - sharding: true, - extension: '.data' - }, - pins: { - sharding: true, - extension: '.data' - } - } - } -}, { - name: 'without sharding', - options: { - storageBackends: { - root: DatastoreFS, - blocks: DatastoreFS, - datastore: DatastoreLevel, - keys: DatastoreLevel, - pins: DatastoreLevel - }, - storageBackendOptions: { - root: { - sharding: false, - extension: '' - }, - blocks: { - sharding: false, - extension: '.data' - }, - datastore: { - sharding: false, - extension: '.data' - }, - keys: { - sharding: false, - extension: '.data' - }, - pins: { - sharding: false, - extension: '.data' - } - } - } -}] - -module.exports = (createRepo, repoCleanup) => { - CONFIGURATIONS.forEach(({ name, options }) => { - describe(name, () => { - require('./migration-8-test')(createRepo, repoCleanup, options) - require('./migration-9-test')(createRepo, repoCleanup, options) - require('./migration-10-test')(createRepo, repoCleanup, options) - }) - }) +module.exports = (createRepo, repoCleanup, repoOptions) => { + require('./migration-8-test')(createRepo, repoCleanup, repoOptions) + require('./migration-9-test')(createRepo, repoCleanup, repoOptions) + require('./migration-10-test')(createRepo, repoCleanup, repoOptions) } diff --git a/test/migrations/migration-9-test.js b/test/migrations/migration-9-test.js index 37a4d4a..db6bd9b 100644 --- a/test/migrations/migration-9-test.js +++ b/test/migrations/migration-9-test.js @@ -184,7 +184,7 @@ module.exports = (setup, cleanup, repoOptions) => { expect(Object.keys(pinned)).to.have.lengthOf(pinset.pins) await datastore.open() - await expect(datastore.has(PIN_DS_KEY)).to.eventually.be.false() + await expect(datastore.has(PIN_DS_KEY)).to.become(false) await datastore.close() }) }) diff --git a/test/node.js b/test/node.js index 6c26abe..94848e1 100644 --- a/test/node.js +++ b/test/node.js @@ -1,65 +1,147 @@ /* eslint-env mocha */ 'use strict' +const os = require('os') +const rimraf = require('rimraf') const DatastoreFS = require('datastore-fs') const DatastoreLevel = require('datastore-level') -const promisify = require('util').promisify -const asyncRimraf = promisify(require('rimraf')) -const { createRepo, createAndLoadRepo } = require('./fixtures/repo') -const os = require('os') +const DatastoreS3 = require('datastore-s3') +const mockS3 = require('./fixtures/mock-s3') +const S3 = require('aws-sdk').S3 +const s3Instance = new S3({ + params: { + Bucket: 'test' + } +}) +mockS3(s3Instance) +const { createRepo } = require('./fixtures/repo') + +function cleanup (dir) { + rimraf.sync(dir) +} -const repoOptions = { - lock: 'fs', - storageBackends: { - root: DatastoreFS, - blocks: DatastoreFS, - keys: DatastoreFS, - datastore: DatastoreLevel, - pins: DatastoreLevel - }, - storageBackendOptions: { - root: { - extension: '' +const CONFIGURATIONS = [{ + name: 'with sharding', + cleanup, + repoOptions: { + storageBackends: { + root: DatastoreFS, + blocks: DatastoreFS, + datastore: DatastoreLevel, + keys: DatastoreLevel, + pins: DatastoreLevel }, - blocks: { - sharding: true, - extension: '.data' + storageBackendOptions: { + root: { + extension: '' + }, + blocks: { + sharding: true, + extension: '.data' + }, + datastore: {}, + keys: {}, + pins: {} + } + } +}, { + name: 'without sharding', + cleanup, + repoOptions: { + storageBackends: { + root: DatastoreFS, + blocks: DatastoreFS, + datastore: DatastoreLevel, + keys: DatastoreLevel, + pins: DatastoreLevel }, - keys: { + storageBackendOptions: { + root: { + extension: '' + }, + blocks: { + sharding: false, + extension: '.data' + }, + datastore: {}, + keys: {}, + pins: {} + } + } +}, { + name: 'with s3', + cleanup: () => {}, + repoOptions: { + lock: 'memory', + storageBackends: { + root: DatastoreS3, + blocks: DatastoreS3, + datastore: DatastoreS3, + keys: DatastoreS3, + pins: DatastoreS3 }, - pins: { + storageBackendOptions: { + root: { + sharding: true, + extension: '', + s3: s3Instance, + createIfMissing: false + }, + blocks: { + sharding: true, + extension: '.data', + s3: s3Instance, + createIfMissing: false + }, + datastore: { + sharding: true, + s3: s3Instance, + createIfMissing: false + }, + keys: { + sharding: true, + s3: s3Instance, + createIfMissing: false + }, + pins: { + sharding: true, + s3: s3Instance, + createIfMissing: false + } } } -} +}] -function repoCleanup (dir) { - return asyncRimraf(dir) -} +CONFIGURATIONS.forEach(({ name, repoOptions, cleanup }) => { + const setup = () => createRepo(repoOptions, os.tmpdir()) -describe('Node specific tests', () => { - describe('lock.js tests', () => { - describe('fs-lock tests', () => { - require('./lock-test')(require('../src/repo/lock'), () => createRepo(repoOptions, os.tmpdir()), repoCleanup, repoOptions) - }) + describe(name, () => { + describe('lock.js tests', () => { + describe('fs-lock tests', () => { + require('./lock-test')(require('../src/repo/lock'), setup, cleanup, repoOptions) + }) - describe('mem-lock tests', () => { - require('./lock-test')(require('../src/repo/lock-memory'), () => createRepo(repoOptions, os.tmpdir()), repoCleanup, repoOptions) + describe('mem-lock tests', () => { + describe(name, () => { + require('./lock-test')(require('../src/repo/lock-memory'), setup, cleanup, repoOptions) + }) + }) }) - }) - describe('version tests', () => { - require('./version-test')(() => createRepo(repoOptions, os.tmpdir()), repoCleanup, repoOptions) - }) + describe('version tests', () => { + require('./version-test')(setup, cleanup, repoOptions) + }) - describe('migrations tests', () => { - require('./migrations')(() => createRepo(repoOptions, os.tmpdir()), repoCleanup) - }) + describe('migrations tests', () => { + require('./migrations')(setup, cleanup, repoOptions) + }) - describe('init tests', () => { - require('./init-test')(() => createRepo(repoOptions, os.tmpdir()), repoCleanup, repoOptions) - }) + describe('init tests', () => { + require('./init-test')(setup, cleanup, repoOptions) + }) - describe('integration tests', () => { - require('./integration-test')(() => createAndLoadRepo(repoOptions, os.tmpdir()), repoCleanup, repoOptions) + describe('integration tests', () => { + require('./integration-test')(setup, cleanup, repoOptions) + }) }) }) From dc6af1926227b2b529337c63435ad229bc62fa66 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 13 Apr 2021 14:32:55 +0100 Subject: [PATCH 2/6] chore: remove duplicate chai --- test/browser.js | 51 +++++++++++++++++++++++++++++ test/fixtures/mock-s3.js | 4 +-- test/migrations/migration-9-test.js | 2 +- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/test/browser.js b/test/browser.js index 8ef2004..6627ebf 100644 --- a/test/browser.js +++ b/test/browser.js @@ -2,6 +2,15 @@ 'use strict' const DatastoreLevel = require('datastore-level') +const DatastoreS3 = require('datastore-s3') +const mockS3 = require('./fixtures/mock-s3') +const S3 = require('aws-sdk').S3 +const s3Instance = new S3({ + params: { + Bucket: 'test' + } +}) +mockS3(s3Instance) const { createRepo } = require('./fixtures/repo') async function deleteDb (dir) { @@ -62,6 +71,48 @@ const CONFIGURATIONS = [{ } } } +}, { + name: 'with s3', + cleanup: () => {}, + repoOptions: { + lock: 'memory', + storageBackends: { + root: DatastoreS3, + blocks: DatastoreS3, + datastore: DatastoreS3, + keys: DatastoreS3, + pins: DatastoreS3 + }, + storageBackendOptions: { + root: { + sharding: true, + extension: '', + s3: s3Instance, + createIfMissing: false + }, + blocks: { + sharding: true, + extension: '.data', + s3: s3Instance, + createIfMissing: false + }, + datastore: { + sharding: true, + s3: s3Instance, + createIfMissing: false + }, + keys: { + sharding: true, + s3: s3Instance, + createIfMissing: false + }, + pins: { + sharding: true, + s3: s3Instance, + createIfMissing: false + } + } + } }] CONFIGURATIONS.forEach(({ name, repoOptions, cleanup }) => { diff --git a/test/fixtures/mock-s3.js b/test/fixtures/mock-s3.js index d79adb7..2d9b812 100644 --- a/test/fixtures/mock-s3.js +++ b/test/fixtures/mock-s3.js @@ -1,9 +1,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -chai.use(require('dirty-chai')) -const expect = chai.expect +const { expect } = require('aegir/utils/chai') const standin = require('stand-in') const { Buffer } = require('buffer') diff --git a/test/migrations/migration-9-test.js b/test/migrations/migration-9-test.js index db6bd9b..37a4d4a 100644 --- a/test/migrations/migration-9-test.js +++ b/test/migrations/migration-9-test.js @@ -184,7 +184,7 @@ module.exports = (setup, cleanup, repoOptions) => { expect(Object.keys(pinned)).to.have.lengthOf(pinset.pins) await datastore.open() - await expect(datastore.has(PIN_DS_KEY)).to.become(false) + await expect(datastore.has(PIN_DS_KEY)).to.eventually.be.false() await datastore.close() }) }) From ad9e6e2dbdddb6fecc549c8be063b86632293661 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 13 Apr 2021 15:00:50 +0100 Subject: [PATCH 3/6] chore: not all datastore types support all lock types --- test/node.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/node.js b/test/node.js index 94848e1..bec82db 100644 --- a/test/node.js +++ b/test/node.js @@ -116,17 +116,15 @@ CONFIGURATIONS.forEach(({ name, repoOptions, cleanup }) => { const setup = () => createRepo(repoOptions, os.tmpdir()) describe(name, () => { - describe('lock.js tests', () => { + if (repoOptions.lock === 'memory') { + describe('mem-lock tests', () => { + require('./lock-test')(require('../src/repo/lock-memory'), setup, cleanup, repoOptions) + }) + } else { describe('fs-lock tests', () => { require('./lock-test')(require('../src/repo/lock'), setup, cleanup, repoOptions) }) - - describe('mem-lock tests', () => { - describe(name, () => { - require('./lock-test')(require('../src/repo/lock-memory'), setup, cleanup, repoOptions) - }) - }) - }) + } describe('version tests', () => { require('./version-test')(setup, cleanup, repoOptions) From 7c44a3030ea2818d835bc6fb4ef913e0c7a2772d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 13 Apr 2021 15:33:37 +0100 Subject: [PATCH 4/6] chore: use datastore-s3 without dependency on ipfs-repo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2eb611f..bc992fb 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "aws-sdk": "^2.884.0", "datastore-fs": "^3.0.0", "datastore-level": "^4.0.0", - "datastore-s3": "^4.0.0", + "datastore-s3": "ipfs/js-datastore-s3#fix/remove-create-s3-repo", "events": "^3.2.0", "it-all": "^1.0.2", "just-safe-set": "^2.1.0", From 63570decde6d63a96842ae487ae5e58ca1cc6411 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 15 Apr 2021 13:15:43 +0100 Subject: [PATCH 5/6] chore: update deps, s3 will be broken --- migrations/migration-8/index.js | 5 ++--- migrations/migration-9/index.js | 2 +- package.json | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/migrations/migration-8/index.js b/migrations/migration-8/index.js index 044ba57..5609946 100644 --- a/migrations/migration-8/index.js +++ b/migrations/migration-8/index.js @@ -54,9 +54,8 @@ async function process (repoPath, repoOptions, onProgress, keyFunction) { let blockCount - blockCount = await length(blockstore.query({ - keysOnly: true, - filters: [({ key }) => { + blockCount = await length(blockstore.queryKeys({ + filters: [(key) => { const newKey = keyFunction(key) return newKey.toString() !== key.toString() diff --git a/migrations/migration-9/index.js b/migrations/migration-9/index.js index e42cf8a..aaa670d 100644 --- a/migrations/migration-9/index.js +++ b/migrations/migration-9/index.js @@ -93,7 +93,7 @@ async function pinsToDAG (blockstore, datastore, pinstore, onProgress) { let recursivePins = [] let directPins = [] let counter = 0 - const pinCount = await length(pinstore.query({ keysOnly: true })) + const pinCount = await length(pinstore.queryKeys({})) for await (const { key, value } of pinstore.query({})) { counter++ diff --git a/package.json b/package.json index bc992fb..9c46ddd 100644 --- a/package.json +++ b/package.json @@ -48,10 +48,10 @@ "dependencies": { "cborg": "^1.0.4", "cids": "^1.0.0", - "datastore-core": "^3.0.0", + "datastore-core": "^4.0.0", "debug": "^4.1.0", "fnv1a": "^1.0.1", - "interface-datastore": "^3.0.3", + "interface-datastore": "^4.0.0", "ipld-dag-pb": "^0.22.1", "it-length": "^1.0.1", "multibase": "^4.0.1", @@ -69,8 +69,8 @@ "aegir": "^33.0.0", "assert": "^2.0.0", "aws-sdk": "^2.884.0", - "datastore-fs": "^3.0.0", - "datastore-level": "^4.0.0", + "datastore-fs": "^4.0.0", + "datastore-level": "^5.0.0", "datastore-s3": "ipfs/js-datastore-s3#fix/remove-create-s3-repo", "events": "^3.2.0", "it-all": "^1.0.2", From 84e42a75f7034f605ea2518b6a14f7d9c0aea66d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 15 Apr 2021 17:14:32 +0100 Subject: [PATCH 6/6] chore: remove gh version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c46ddd..4fd5c17 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "aws-sdk": "^2.884.0", "datastore-fs": "^4.0.0", "datastore-level": "^5.0.0", - "datastore-s3": "ipfs/js-datastore-s3#fix/remove-create-s3-repo", + "datastore-s3": "^5.0.0", "events": "^3.2.0", "it-all": "^1.0.2", "just-safe-set": "^2.1.0",