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

feat: files.unlink #1101

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/core/components/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,22 @@ module.exports = function files (self) {
},

lsPullStreamImmutable: _lsPullStreamImmutable
}
},

unlink: promisify((ipfsPath, callback) => {
const cid = new CID(ipfsPath)
self._ipldResolver.get(cid, (err, node) => {
if (err) {
return callback(err)
}
pull(
pull.values(node.value.links),
pull.drain(
link => self._ipldResolver.bs.delete(new CID(link.multihash)),
() => self._ipldResolver.bs.delete(cid, callback)
)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will delete 1 level of links, but if the links have links then they should also be deleted as per pin rm --recursive.

})
})

}