Hey guys!
I think there’s some misconception:
A CID is a pin. You can unpin or pin a CID.
If you unpin it, the garbage collection will remove it after a while.
If the CID contains a folder, the ‘ipfs files ls’ can also list it’s content.
To use ipfs files rm the CID must be locally stored as a file/folder, not just pinned.
You can pin a folder locally like this:
‘ipfs files cp /ipfs/$CID /time_travel_stuff’
Locally stored files and folders can be removed from the local directory again:
‘ipfs files rm /time_travel_stuff’
A CID local file/folder must be addressed with their local path, not the CID, because it’s basically just a ‘link’ to a CID you’re removing.
You can for example link one CID at two places, without storing the data twice:
‘ipfs files cp /ipfs/$CID /home-movies/2019-04/swimming-pool.mp4’
And add it at a different location:
‘ipfs files cp /ipfs/$same_CID /shares/mike/home-movie-swimming-pool.mp4’
You can now share the CID of /shares/mike with Mike to allow him to find the video.
If you want to remove the file again from the folder, you can just run
‘ipfs files rm /shares/mike/home-movie-swimming-pool.mp4’
Add other stuff and share the new CID of the folder again with Mike.
Note: All changes to a folder will change it’s CID, so Mike can still access the old version with the old CID and access also the movie after you removed it from your folder.
Never expect that you can remove stuff from IPFS after you added it, it’s not meant to be used that way.