File Removal

Operation

Added during release 1.0.0, BTFS now allows for the removal of uploaded files and directories. The btfs rm command removes all references to a hash in the merkledag.

Remove File

To remove a file, run btfs rm <file hash>:

// Add the file angellanding.jpg

User-MacBook-Pro: user$ btfs add angellanding.jpg
added QmNRNVAoXmSEVWVVwbmDiCvbRm7gvzCiHRtwMca5ohjKoV angellanding.jpg
 242.61 KiB / 242.61 KiB [===========================================================] 100.00%


// Remove the file angellanding.jpg

User-MacBook-Pro: user$ btfs rm QmNRNVAoXmSEVWVVwbmDiCvbRm7gvzCiHRtwMca5ohjKoV
Removed QmNRNVAoXmSEVWVVwbmDiCvbRm7gvzCiHRtwMca5ohjKoV

Remove Directory

To remove a directory, run the same command, with pointing to the directory hash:

// Add the directory "rentalapp"

User-MacBook-Pro: user$ btfs add -r rentalapp
added QmYzttAgYRNuqmhsdPQCHSyn1DhBKXzMPNoQV562jysx6e rentalapp/AppIdea.graffle/data.plist
added QmNVk31BvEdpsvCgKkhRC9D2WSHeEv6cU1hMkp5PFzMWCH rentalapp/AppIdea.graffle/image2.jpg
added QmPUFWsMrXKEpJat1NuKgHxLinFb4dxuoNHnGQSD7KPff8 rentalapp/AppIdea.graffle/image3.png
added QmZUcwPuFF7JdZ3vg4DPUM86GSa6LT41zjAGd9qaUHiedL rentalapp/AppIdea.graffle/image4.png
added QmWzYuoLpnuhDpjFEdKfdZd9csm67Ets2nJGNGxtJG4E12 rentalapp/AppIdea.graffle/image6.png
added Qmd4vXCHTmTVz4kGhoUGeVWe8mxyrTzYMBLQAVWb7BnLud rentalapp/AppIdea.graffle/image7.png
added QmPDkUPr6xDsUotTZoaR6BgXjh6Un9k9DqK1cNUZz2Cjpy rentalapp/hello.txt
added QmPFcSF8rRa6ovxuqVJC76pgAZPemTu2nTe7quPuMid1Pe rentalapp/AppIdea.graffle
added QmVDqDEUD5vJEf6iYju8TYuShamyjgQTe2vfFgaEMVYkRn rentalapp
 2.07 MiB / 2.08 MiB [======================================================================================================================================================]  99.72%
 
// Remove the directory "rentalapp" 
 
User-MacBook-Pro: user$ btfs rm QmVDqDEUD5vJEf6iYju8TYuShamyjgQTe2vfFgaEMVYkRn
Removed QmPFcSF8rRa6ovxuqVJC76pgAZPemTu2nTe7quPuMid1Pe
Removed QmPDkUPr6xDsUotTZoaR6BgXjh6Un9k9DqK1cNUZz2Cjpy
Removed QmVDqDEUD5vJEf6iYju8TYuShamyjgQTe2vfFgaEMVYkRn

Removing a directory in BTFS results in removing the hashes of individual files in the directory, as well as the hash corresponding to the directory itself.