Macchina-CLI / libmacchina

A library providing access to all sorts of system information.
https://crates.io/crates/libmacchina
MIT License
68 stars 20 forks source link

Possible bug in machine field ? #48

Closed uttarayan21 closed 3 years ago

uttarayan21 commented 3 years ago

Screenshot from 2021-06-23 20-06-54

My laptop broke so the discovery to this :)

grtcdr commented 3 years ago

Ah dang it!

That phrase should not show up... It should be replacing "To be filled by O.E.M." with an empty string whenever it finds it, but for some reason it's printing that instead. Can you check if the files that we're reading from aren't actually the cause so we can pinpoint where the issue is creeping up from?

uttarayan21 commented 3 years ago

Here you go ! Screenshot from 2021-06-23 20-41-12 I have no clue what is supposed to be in there but it seems that .replace probably isn't replacing multiple "To be filled by O.E.M" strings.

grtcdr commented 3 years ago

I have no clue what is supposed to be in there but it seems that .replace probably isn't replacing multiple "To be filled by O.E.M" strings.

Yup, I'll :mag_right: investigate the issue.

grtcdr commented 3 years ago

Uhm, I'm not exactly sure why this is occuring, the part where data provided by the files is processed before being returned looks good as far as I can tell... :confused:

uttarayan21 commented 3 years ago

I'll try to debug this later since college is really hectic right now.

grtcdr commented 3 years ago

I'll try to debug this later since college is really hectic right now.

I bet, it was really stressful these couple weeks for me too, good luck with everything :smile:

grtcdr commented 3 years ago

Found the culprit!

Right around the end of linux::machine() we have:

if family == name && family == version {
            return Ok(family);
        } else if version.is_empty() || version.len() <= 15 {
            return Ok(new_product.into_iter().join(" "));
        }

        Ok(version)

First condition & second condition are not satisfied, so it ends up returning version, which in your case is "To be filled..."

grtcdr commented 3 years ago

I hate the diversity of the information that manufacturers provide or don't provide in this case. We'll have to add a new set of conditions or somehow simplify it and make it a lot more maintainable for the future.