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

Incorrect syntax use in load config function #37

Open
jewel-snake opened this issue Nov 21, 2023 · 0 comments
Open

Incorrect syntax use in load config function #37

jewel-snake opened this issue Nov 21, 2023 · 0 comments

Comments

@jewel-snake
Copy link

I have built this project and discovered that it fails no difference whether ~/.config/lefthk/config.ron exists or not.
Error message looks like this:
ERROR lefthk: Unable to load new config due to error: No config file found.
So I looked into source code and found this:

pub fn load() -> Result<Config> {
    let path = BaseDirectories::with_prefix(lefthk_core::LEFTHK_DIR_NAME)?;
    fs::create_dir_all(path.get_config_home())?;
    let file_name = path.place_config_file("config.ron")?;
    if Path::new(&file_name).exists() {
        let contents = fs::read_to_string(file_name)?;
        Config::try_from(contents)?;
    }
    Err(LeftError::NoConfigFound)
}

This piece of code never returns Result::Ok . So I changed it to:

pub fn load() -> Result<Config> {
    let path = BaseDirectories::with_prefix(lefthk_core::LEFTHK_DIR_NAME)?;
    fs::create_dir_all(path.get_config_home())?;
    let file_name = path.place_config_file("config.ron")?;
    if Path::new(&file_name).exists() {
        let contents = fs::read_to_string(file_name)?;
        return Config::try_from(contents);
    }
    Err(LeftError::NoConfigFound)
}

here's link to mentioned function
https://github.com/leftwm/lefthk/blob/29819976d562841b92e0447e19e945759d5f3e89/lefthk/src/config/mod.rs#L67C1-L76C2

hope it helps:)

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

1 participant