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

Feature: rescan folder command #9

Open
imsnif opened this issue Jun 17, 2020 · 4 comments
Open

Feature: rescan folder command #9

imsnif opened this issue Jun 17, 2020 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@imsnif
Copy link
Owner

imsnif commented Jun 17, 2020

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.

@imsnif imsnif added help wanted Extra attention is needed good first issue Good for newcomers labels Jun 17, 2020
@mhdmhsni
Copy link
Contributor

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.

@imsnif
Copy link
Owner Author

imsnif commented Sep 11, 2020

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.

@imsnif imsnif removed the good first issue Good for newcomers label Sep 11, 2020
@mhdmhsni
Copy link
Contributor

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.

@imsnif
Copy link
Owner Author

imsnif commented Sep 11, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants