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

Detect whether OS is Windows Server #5089

Merged
merged 3 commits into from
Sep 4, 2023
Merged

Conversation

dlon
Copy link
Member

@dlon dlon commented Sep 4, 2023

We do not officially support Windows Server, but we could still distinguish between it and the desktop OSes. Currently, we incorrectly assume that the user is necessarily on the desktop version.

This code simply returns "Windows Server" and does not bother to detect the specific version/year. This is fine because we log the build number as well, and the main point is to distinguish between desktop and server.


This change is Reviewable

@dlon dlon requested a review from faern September 4, 2023 08:30
@linear
Copy link

linear bot commented Sep 4, 2023

DES-339 Include "Server" in problem report for Windows server

Currently the problem reports on Windows does not convey if the user is running the server or desktop version of Windows. The vast majority of users of course run desktop and no change should be made there. But if we detect that the user runs the server version it could be nice if the string "Server" was added somewhere in the platform string.

Should be possible to identify with the wProductType field we already have access to.

@dlon dlon force-pushed the detect-windows-server-des-339 branch from d13404e to 85efc02 Compare September 4, 2023 08:32
Copy link
Member

@faern faern left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @dlon)


talpid-platform-metadata/src/windows.rs line 32 at r1 (raw file):

        .map(|version| version.windows_version_string())
        .unwrap_or("N/A".into());
    format!("Windows {}", version_string)

This is IMHO a bit harder to understand than the old version. Because now the reader has to check in more places to know if the prefix "Windows" is part of the string or not. This PR currently goes from hardcoding "Windows" in two places to having it in three places.

Personally I think I would have preferred to keep "Windows" out of windows_version_string and just have it return "Server" when it detects server. Not going to block the PR on this, but it's my suggestion for an improvement.


talpid-platform-metadata/src/windows.rs line 42 at r1 (raw file):

}

pub struct WindowsVersion {

Is there any reason this struct is public? I can't find any usage of it outside of this module. I'm asking because the currenly public facing method WindowsVersion::windows_version_string now changed format (The word "Windows" was added to the start) and I was unsure what parts of the app this would affect.

If this struct is indeed not used outside of this module, let's make it private to better show that.

Copy link
Member

@faern faern left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dlon)

Copy link
Member Author

@dlon dlon left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @faern)


talpid-platform-metadata/src/windows.rs line 32 at r1 (raw file):

Previously, faern (Linus Färnstrand) wrote…

This is IMHO a bit harder to understand than the old version. Because now the reader has to check in more places to know if the prefix "Windows" is part of the string or not. This PR currently goes from hardcoding "Windows" in two places to having it in three places.

Personally I think I would have preferred to keep "Windows" out of windows_version_string and just have it return "Server" when it detects server. Not going to block the PR on this, but it's my suggestion for an improvement.

Done.


talpid-platform-metadata/src/windows.rs line 42 at r1 (raw file):

Previously, faern (Linus Färnstrand) wrote…

Is there any reason this struct is public? I can't find any usage of it outside of this module. I'm asking because the currenly public facing method WindowsVersion::windows_version_string now changed format (The word "Windows" was added to the start) and I was unsure what parts of the app this would affect.

If this struct is indeed not used outside of this module, let's make it private to better show that.

Nope, we do not use it elsewhere. Done.

Copy link
Member

@faern faern left a comment

Choose a reason for hiding this comment

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

Sweet! Overall way fewer changes and IMHO nicer code. This is perfect :lgtm:

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@dlon dlon force-pushed the detect-windows-server-des-339 branch from 693775c to f5d8551 Compare September 4, 2023 14:29
@dlon dlon merged commit 6c10580 into main Sep 4, 2023
25 checks passed
@dlon dlon deleted the detect-windows-server-des-339 branch September 4, 2023 14:34
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