Skip to content

Commit

Permalink
refactor: simplify version fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Sep 23, 2023
1 parent c5442cb commit 90f32c8
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,15 @@ export default async function init (inQuickImport = false) {
async function fetchKuboRpcBackendVersion () {
// prefer AgentVersion string from 'ipfs id' , but if that fails, use 'ipfs version'
try {
const id = await ipfs.id()
if (id) {
return id.agentVersion
const { agentVersion } = await ipfs.id()
if (agentVersion) {
return agentVersion
}
} catch (_) {
try {
const v = await ipfs.version()
if (v) {
return v.commit ? v.version + '/' + v.commit : v.version
}
} catch (_) {
const { version, commit } = await ipfs.version()
if (version || commit) {
return [version, commit].filter(Boolean).join('/')
}
}
} catch (_) {}
return null
}

Expand Down

0 comments on commit 90f32c8

Please sign in to comment.