Ipfs add --copy should replace duplicate blocks
Checklist
- [X] My issue is specific & actionable.
- [X] I am not suggesting a protocol enhancement.
- [X] I have searched on the issue tracker for my issue.
Description
I think this particular issue has been brought up in different contexts, (https://github.com/ipfs/kubo/issues/8948), but here's a practical example.
Folder A is added to ipfs with --nocopy Folder B is added with --nocopy. Folder B contains blocks that are duplicated with Folder A
Later, Folder A is removed, (Upinned, Removed from MSF, and deleted from host filesystem)
The blocks that used to be duplicated by Folder A will no longer be available. (they still reference the files in Folder A)
Even a garbage collection and re-adding Folder B will not correct this issue. The only easy way to fix this, once the problem is perceived, it Unpin Folder B, run Garbage Collection, then Re-add Folder B
My proposal here is that when ipfs add --nocopy finds a dubplicate block, it should replace the reference to the new file (this could be optional if there is a case for not doing so.) That way, missing blocks could always be restored by re-adding all the content, without having to unpin and gc first.