Skip to content

Commit

Permalink
refactor: support Pinning.RemoteServices["name"]
Browse files Browse the repository at this point in the history
This adds fallback to new notation
from ipfs/kubo#8096

We default to old one because new one matters only when '.' is present
in service name
  • Loading branch information
lidel committed Apr 28, 2021
1 parent 88d8e5a commit 1c77960
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bundles/pinning.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ const mfsPolicyEnableFlag = memoize(async (serviceName, ipfs) => {
try {
return await ipfs.config.get(`Pinning.RemoteServices.${serviceName}.Policies.MFS.Enable`)
} catch (e) {
console.error(`unexpected config.get error for "${serviceName}"`, e)
return false
if (e.message?.includes('Pinning.RemoteServices key has no attributes')) {
try { // retry with notation from https://github.com/ipfs/go-ipfs/pull/8096
return await ipfs.config.get(`Pinning.RemoteServices["${serviceName}"].Policies.MFS.Enable`)
} catch (_) {}
}
console.error(`unexpected config.get error for "${serviceName}": ${e.message}`)
}
return false
}, { maxAge: 3000 })

const uniqueCidBatches = (arrayOfCids, size) => {
Expand Down

0 comments on commit 1c77960

Please sign in to comment.