-
Notifications
You must be signed in to change notification settings - Fork 864
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enable cidv1 for future versions
- Loading branch information
Showing
4 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const store = require('./common/store') | ||
const getCtx = require('./context') | ||
const logger = require('./common/logger') | ||
|
||
module.exports = async function () { | ||
const shouldUseCIDv1 = store.get('ipfsConfig.useCIDv1', true) | ||
|
||
if (shouldUseCIDv1) { | ||
logger.info('[enable-cid-v1]: Attempting to enable CID version 1 for files') | ||
const ctx = getCtx() | ||
const getIpfsd = await ctx.getProp('getIpfsd') | ||
/** @type {import('ipfsd-ctl').Controller|null} */ | ||
const ipfsd = await getIpfsd() | ||
if (!ipfsd) { | ||
logger.error('[enable-cid-v1]: Could not get IPFS daemon controller') | ||
return | ||
} | ||
logger.info('[enable-cid-v1]: Enabling CID version 1 for files') | ||
try { | ||
// @ts-expect-error - ipfsd.api is not typed properly | ||
await ipfsd.api.files.chcid('/', { cidVersion: 1 }) | ||
logger.info('[enable-cid-v1]: CID version 1 enabled for files') | ||
} catch (e) { | ||
logger.error('[enable-cid-v1]: Failed to enable CID version 1 for files', e) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters