Skip to content

Commit

Permalink
Fix handling options in promise API
Browse files Browse the repository at this point in the history
  • Loading branch information
RangerMauve committed Aug 31, 2019
1 parent cf157ce commit 8d24b0a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,21 @@ module.exports = function SDK (opts) {

let archive = null

const localOptions = {
persist: false
}

if (key) {
if (!options.persist) {
options.persist = false
}
if (isLocal(key)) {
options.persist = true
localOptions.persist = true
}
archive = Hyperdrive(key, options)
const finalOptions = Object.assign(localOptions, options)
archive = Hyperdrive(key, finalOptions)
} else {
archive = Hyperdrive(null, {
persist: true
})
localOptions.persist = true
const finalOptions = Object.assign(localOptions, options)

archive = Hyperdrive(null, finalOptions)
addLocal(archive.metadata.key.toString('hex'))
}

Expand Down Expand Up @@ -463,8 +466,8 @@ module.exports = function SDK (opts) {
return archive
}

static async load (url) {
const archive = new DatArchive(url)
static async load (url, options) {
const archive = new DatArchive(url, options)

await archive._loadPromise

Expand Down

0 comments on commit 8d24b0a

Please sign in to comment.