Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 1a96c39

Browse files
committed
fix(ipfs-core): fix repo gc typing
1 parent db4d9d1 commit 1a96c39

File tree

1 file changed

+7
-2
lines changed
  • packages/ipfs-core/src/components/repo

1 file changed

+7
-2
lines changed

packages/ipfs-core/src/components/repo/gc.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const BLOCK_RM_CONCURRENCY = 256
1717
* @typedef {import('ipfs-core-types/src/refs').API} RefsAPI
1818
* @typedef {import('ipfs-repo')} IPFSRepo
1919
* @typedef {import('interface-datastore').Key} Key
20+
* @typedef {import('ipfs-repo/src/types').Block} Block
2021
*/
2122

2223
/**
@@ -101,7 +102,7 @@ async function createMarkedSet ({ pin, refs, repo }) {
101102
* @param {object} arg
102103
* @param {IPFSRepo} arg.repo
103104
* @param {Set<string>} markedSet
104-
* @param {AsyncIterable<CID>} blockKeys
105+
* @param {AsyncIterable<CID|Block>} blockKeys
105106
*/
106107
async function * deleteUnmarkedBlocks ({ repo }, markedSet, blockKeys) {
107108
// Iterate through all blocks and find those that are not in the marked set
@@ -110,12 +111,16 @@ async function * deleteUnmarkedBlocks ({ repo }, markedSet, blockKeys) {
110111
let removedBlocksCount = 0
111112

112113
/**
113-
* @param {CID} cid
114+
* @param {Block|CID} cid
114115
*/
115116
const removeBlock = async (cid) => {
116117
blocksCount++
117118

118119
try {
120+
if (!CID.isCID(cid)) {
121+
return null
122+
}
123+
119124
const b32 = multibase.encode('base32', cid.multihash).toString()
120125

121126
if (markedSet.has(b32)) {

0 commit comments

Comments
 (0)