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

Commit acd355d

Browse files
committed
Files: add unlink files
License: MIT Signed-off-by: Jorge Ludlow <[email protected]>
1 parent 71faa92 commit acd355d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/core/components/files.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,5 +282,22 @@ module.exports = function files (self) {
282282
},
283283

284284
lsPullStreamImmutable: _lsPullStreamImmutable
285-
}
285+
},
286+
287+
unlink: promisify((ipfsPath, callback) => {
288+
const cid = new CID(ipfsPath)
289+
self._ipldResolver.get(cid, (err, node) => {
290+
if (err) {
291+
return callback(err)
292+
}
293+
pull(
294+
pull.values(node.value.links),
295+
pull.drain(
296+
link => self._ipldResolver.bs.delete(new CID(link.multihash)),
297+
() => self._ipldResolver.bs.delete(cid, callback)
298+
)
299+
)
300+
})
301+
})
302+
286303
}

0 commit comments

Comments
 (0)