feat(installer): block desktop edition installer on handheld devices#167
feat(installer): block desktop edition installer on handheld devices#167
Conversation
Signed-off-by: Peter Jung <admin@ptr1337.dev>
There was a problem hiding this comment.
Pull request overview
This PR adds functionality to block the desktop edition installer when running on handheld devices, improving the user experience by preventing unsupported configurations. The change refactors the edition_compat_check function to detect handheld hardware and enforce edition compatibility rules bidirectionally.
Changes:
- Refactored edition compatibility checking to detect handheld devices and block desktop edition installation on such hardware
- Improved error handling by replacing
.expect()with propermatchstatement for profile parsing - Added comprehensive translations for the new warning message across all 26 supported languages
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/installer.rs | Refactored edition_compat_check function to detect handheld devices, block desktop edition on handheld hardware, and improve error handling |
| i18n/*/cachyos_hello.ftl (26 files) | Added desktop-on-handheld-warning translation key across all supported languages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Ok(profiles) => profiles, | ||
| Err(e) => { | ||
| error!("Failed to parse handheld profiles: {e}"); | ||
| return true; |
There was a problem hiding this comment.
If parsing handheld profiles fails, the function returns true (allowing installation to proceed). This means that if the profiles file is missing, corrupted, or has parse errors, both the handheld edition compatibility check and the desktop edition blocking check will be bypassed. Consider whether this fail-open behavior is appropriate for security/UX, or if a more conservative approach (returning false to block installation when profiles cannot be loaded) would be safer.
| return true; | |
| return false; |
| if edition_tag == "handheld" && !is_handheld_device { | ||
| ui.show_message(MessageType::Warning, &fl!("unsupported-hw-warning"), message.clone()); | ||
| return true; | ||
| } | ||
|
|
||
| if edition_tag.contains("desktop") && is_handheld_device { |
There was a problem hiding this comment.
There's an inconsistency in how edition tags are checked: line 93 uses exact equality (edition_tag == "handheld") while line 98 uses substring matching (edition_tag.contains("desktop")). This means handheld variants like "handheld-steamdeck" would not be caught by the first check but desktop variants like "desktop-kde" would be caught by the second. Consider using .contains("handheld") on line 93 for consistency, or document why exact matching is required for handheld editions.
| let edition_tag = | ||
| fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string()).trim().to_string(); |
There was a problem hiding this comment.
The .trim().to_string() pattern is used to clean whitespace from the file content, which is good. However, this is applied inconsistently across the file: line 25 uses .trim().into() while line 74 uses .trim().to_string(). Both accomplish the same thing, but for consistency, consider using the same pattern throughout.
| let edition_tag = | |
| fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".to_string()).trim().to_string(); | |
| let edition_tag: String = | |
| fs::read_to_string("/etc/edition-tag").unwrap_or("desktop".into()).trim().into(); |
No description provided.