szabodanika / microbin

A secure, configurable file-sharing and URL shortening web app written in Rust.
https://microbin.eu
BSD 3-Clause "New" or "Revised" License
2.63k stars 160 forks source link

Force delete does not delete the file from the host dir #35

Closed binuengoor closed 2 years ago

binuengoor commented 2 years ago

A pasta set to expire after say, 24 hours does get deleted from the UI as well as the underlying directory. However if we force "Remove" from pasta list, then the file remains in the host directory. I am currently running a small script to clear them every 24 hours or so, but its not ideal.

When we select "Remove" from UI, it is being cleared from the database.json file. but it should also clear data from directory.

szabodanika commented 2 years ago

Thanks for reporting this @binuengoor, hopefully we can get this fixed soon. I am able to reproduce the same issue on the latest revision.

At a quick glance to me it seems like src/endpoints/remove.rs does not implement any file deletion, only updating the pasta model. The file src/util/misc.rs contains the remove_expired function called every time you interact with your MicroBin server and deletes the files for the pastas as well on expiration (in theory, I will need to re-test this). If we find that remove_expired works fine, we can simply update the pasta model and expire the selected pasta before the remove_expired call and that would instantly delete the attachment.