Open imsnif opened 4 years ago
Hey @imsnif. I'm trying to implement this feature but i'm stuck exactly at the point which user should press y
in Are you sure you want to rescan? modal and actually rescan the entire folder. i thought i might be able to add a new instruction and a new event to do this but unfortunately i just can't figure out how to do this exactly. Are there any specific functions that i can use? any hints or tips will be appreciated.
thanks.
Hey @mhdmhsni - I'm happy to hear you're working on this.
So looking at the code, this is indeed a little tricky. The parts we need to re-run are these: https://github.com/imsnif/diskonaut/blob/main/src/main.rs#L158-L200 => here is the actual hard disk scanning https://github.com/imsnif/diskonaut/blob/main/src/main.rs#L204-L220 => this controls the loading animation
As you probably saw on your own, these are two threads that start when the application loads and die when they are done (when the application is loaded). I think the best option would be to move these two out of main.rs into their own struct (maybe something like LoadFromDisk
?) Once we've done that, we can add a channel receiver to this struct (like the instructions/events, just a new one which we'll need to find a name for :) ), and then send instructions to it from the App.
I think placing the "good first issue" label here was a mistake on my part, since it's a little more complex than I thought. If however you would like to tackle this, I'd be happy to provide you with whatever help I can.
Thank you @imsnif for the good hints. i knew about the hd_scanner
and loading_loop
threads. my problem was i could not figure out how to re-execute those jobs and now it's clear to me (obviously i was looking at the problem from a WRONG perspective!! :) ). i'll give this one another try if you don't mind of course, and let you know if i need any other help.
Sure thing! Just a recommendation: I imagine this would require quite some restructuring, so feel free to make drafts of the implementation (just hacking something together that works without worrying too much about tests/clean code, etc.) so that I can comment on them early before you've done a huge amount of work on them. :)
When pressing "r", the app should prompt the user with an "Are you sure?" modal, and then rescan the entire folder. This is good in case the contents of the folder have changed since the app was open and we don't want to exit the app and enter it again.