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

Commit ab28636

Browse files
committed
Add usage of storageBackendOptions for correct datastore instantiation
1 parent cb19e52 commit ab28636

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

migrations/migration-8/index.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function processFolder (store, prefix, fileNameProcessor) {
2929
prefix: `/${prefix}`
3030
}
3131

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

4444
async function migrate (repoPath, options, isBrowser) {
45-
let storageBackend
45+
let storageBackend, storageBackendOptions
4646
if (options !== undefined
4747
&& options['storageBackends'] !== undefined
4848
&& options['storageBackends']['keys'] !== undefined
@@ -52,7 +52,16 @@ async function migrate (repoPath, options, isBrowser) {
5252
storageBackend = Datastore
5353
}
5454

55-
const store = new storageBackend(path.join(repoPath, 'keys'), { extension: '.data' })
55+
if (options !== undefined
56+
&& options['storageBackendOptions'] !== undefined
57+
&& options['storageBackendOptions']['keys'] !== undefined
58+
) {
59+
storageBackendOptions = options['storageBackendOptions']['keys']
60+
} else {
61+
storageBackendOptions = {}
62+
}
63+
64+
const store = new storageBackend(path.join(repoPath, 'keys'), storageBackendOptions)
5665
try {
5766
const info = processFolder(store, 'info', encode)
5867
const data = processFolder(store, 'pkcs8', encode)
@@ -71,7 +80,7 @@ let storageBackend
7180
) {
7281
storageBackend = options['storageBackends']['keys']
7382
} else {
74-
storageBackend = Datastore
83+
storageBackend = FSDatastore
7584
}
7685

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

0 commit comments

Comments
 (0)