please add a refresh button
The cleaning process is iterative: you run the tool (Spaceman), choose a couple of things to delete, and then you want to run it again to see what to delete next. Could you please add a "refresh" button (or re-run) so no need to select the disk again saving some clicks?
Hello there. I was planning to implement filesystem monitoring instead to receive live updates.
I thought I would have to write platform specific code for this so I waited on it, but it seems that someone made a cross-platform filesystem watching library. https://docs.rs/notify/latest/notify/ It might not work on MacOS due to security limitations, and might be limited to a certain file count limit on Linux but should work mostly fine.
I think it's a better solution than the refresh button but I'll have to test how well it performs. It might fall back to showing a refresh button if it's not available on the platform. Once again thanks for the suggestions :)
@salihgerdan I kept thinking, maybe an "automatic" refresh might not be good, since many times one deletes more than one directory before the next "refresh", so you would end up getting many notifications. Maybe you could group them by delta time between, and triggering the automatic refresh after some time elapsed without notifications, meaning that the user already did all the deletions. But I think this might get complicated, I think that for now a simple refresh button would be good enough.
But I think this might get complicated, I think that for now a simple refresh button would be good enough.
It's a technique called debounce.
You could set a debounce window of 3 seconds for example, and the operation is not performed until that cooldown is reached, when the trigger (watch notification) occurs again before that time has passed it'll reset the timer and repeat the process.
- Generic crate providing this functionality: https://docs.rs/debounce/latest/debounce/
-
Notify crate itself has it's own implementations;
- https://docs.rs/notify-debouncer-mini/latest/notify_debouncer_mini/
- https://docs.rs/notify-debouncer-full/latest/notify_debouncer_full/
It might not work on MacOS due to security limitations, and might be limited to a certain file count limit on Linux but should work mostly fine.
As the docs clarify, in both situations you can use the poll watcher. There's also a mention that it's probably not wise to watch the entire filesystem, so a refresh button is probably a better choice.
Alternatively, as you crawl through the filesystem, you could pay attention to the number of files and conditionally watch if the view isn't a massive amount of files 🤷♂️ (or just go with a refresh button, and an alternative "auto" refresh toggle button).
If you get bug reports about the "auto" refresh UX, then add a prompt or similar guard to raise user awareness about the feature only being appropriate when there's not too many files to watch?
I experimented with polling or monitoring files, but decided to move away from it for now. I realized most of the need for this comes from the lack of any context menu options to delete files and I just finished adding a "Move to Trash" button in the newest commits. (working on a "Permanently Delete" button as well) Because this is done by the program, it allows updating the tree with the change, with no need to poll or monitor. This will be included in a release soon. I did add the refresh button in case outside modification is done. This ended up being rather crude because it simply scraps the old scan data and starts from scratch, instead of updating with new data, but it works decently enough with the aid of OS filesystem caching. I will still consider implementing monitoring in the future.