Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Add usage of storageBackendOptions for correct datastore instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau committed Jul 1, 2019
1 parent 40dc6c8 commit 9718d25
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions migrations/migration-8/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function processFolder (store, prefix, fileNameProcessor) {
prefix: `/${prefix}`
}

const files = await store.query(query)
const files = store.query(query)
for await (let file of files) {
const name = String(file.key._buf).replace(`/${prefix}/`, '')
const encodedFileName = fileNameProcessor(name)
Expand All @@ -42,7 +42,7 @@ async function processFolder (store, prefix, fileNameProcessor) {
}

async function migrate (repoPath, options, isBrowser) {
let storageBackend
let storageBackend, storageBackendOptions
if (options !== undefined
&& options['storageBackends'] !== undefined
&& options['storageBackends']['keys'] !== undefined
Expand All @@ -52,7 +52,16 @@ async function migrate (repoPath, options, isBrowser) {
storageBackend = Datastore
}

const store = new storageBackend(path.join(repoPath, 'keys'), { extension: '.data' })
if (options !== undefined
&& options['storageBackendOptions'] !== undefined
&& options['storageBackendOptions']['keys'] !== undefined
) {
storageBackendOptions = options['storageBackendOptions']['keys']
} else {
storageBackendOptions = {}
}

const store = new storageBackend(path.join(repoPath, 'keys'), storageBackendOptions)
try {
const info = processFolder(store, 'info', encode)
const data = processFolder(store, 'pkcs8', encode)
Expand All @@ -71,7 +80,7 @@ let storageBackend
) {
storageBackend = options['storageBackends']['keys']
} else {
storageBackend = Datastore
storageBackend = FSDatastore
}

const store = new storageBackend(path.join(repoPath, 'keys'), { extension: '.data' })
Expand Down

0 comments on commit 9718d25

Please sign in to comment.