Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please add a refresh button #3

Open
dgutson opened this issue Aug 13, 2023 · 4 comments
Open

please add a refresh button #3

dgutson opened this issue Aug 13, 2023 · 4 comments

Comments

@dgutson
Copy link

dgutson commented Aug 13, 2023

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?

@salihgerdan
Copy link
Owner

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 :)

@dgutson
Copy link
Author

dgutson commented Aug 16, 2023

@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.

@polarathene
Copy link

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.


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?

@salihgerdan
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants