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

arg --fix-db won't panic anymore #104

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

restalex
Copy link

@restalex restalex commented Jan 9, 2025

...due to missing directory or unexpected files.

  • Idiot-proofing the use of --clear-cache before --fix-db (cause I am one)
  • --fix-db does not panic anymore if a file has no extensions according to the extension() method. Happened to me with the .directory files that uses the dolphin file explorer.
  • added a description for --clear-cache if an invalid argument is given. (adding a -h argument could be nice too?)

However --fix-db does not lauch the TUI after being done, nor it removes any of the faulty json or mp4 files, which option seems best?

I quite like this project, as it has all the base features I want for a YTmusic player. So I eventually decided to contribute even if I'm a newcomer to rust.
I will try to work on #93 and/or #88 on my spare time, because I need that the most.

@ccgauche
Copy link
Owner

Thanks a lot for the contribution. I left you some areas for improvements. What would be the use of the -h argument ?

@restalex
Copy link
Author

Second commit is the end of the --fix-db:

  • a lot of match cases to properly dispose of the jsons
  • fixed the clean task, that was not deleting orphan mp4s. The ends_with() example recommends to use extension() instead.

Third commit is an example of what i mean by an -h argument, just a small explanation of what ytermusic is and can do. And especially the shortcuts that I often forget.

path.file_name()
);
if !cache_folder.is_dir() {
println!("[WARN] No download directory found in Cache",);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In rust, you don't need the comma after the format string if no arguments are given.

Suggested change
println!("[WARN] No download directory found in Cache",);
println!("[WARN] The download folder in the cache wasn't found `{cache_folder}`");

);
if !cache_folder.is_dir() {
println!("[WARN] No download directory found in Cache",);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use cargo fmt to format the code

if !cache_folder.is_dir() {
println!("[WARN] No download directory found in Cache",);
}
else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use an else prefer using a return to end the function there.

}
// TODO : really fix the db (delete bad files and rewrite the db.bin)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a good idea indeed!

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

Successfully merging this pull request may close these issues.

2 participants