mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-10-01 05:29:40 +02:00
fix: download zip instead of exe
This commit is contained in:
1 parent
dea0181009
commit
5dfe7cb216
2 files changed
+19
-3
No files matched your search
@@ -612,7 +612,7 @@ mod windows {
|
|||||||
if let Ok(entries) = std::fs::read_dir(install_dir) {
|
if let Ok(entries) = std::fs::read_dir(install_dir) {
|
||||||
for entry in entries.flatten() {
|
for entry in entries.flatten() {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path.extension().is_some_and(|ext| ext == "exe") {
|
if path.extension().is_some_and(|ext| ext == "exe") && is_pe_executable(&path) {
|
||||||
let name = path
|
let name = path
|
||||||
.file_stem()
|
.file_stem()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
@@ -716,7 +716,7 @@ mod windows {
|
|||||||
for entry in entries.flatten() {
|
for entry in entries.flatten() {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
if path.extension().is_some_and(|ext| ext == "exe") {
|
if path.extension().is_some_and(|ext| ext == "exe") && is_pe_executable(&path) {
|
||||||
let name = path
|
let name = path
|
||||||
.file_stem()
|
.file_stem()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
@@ -1185,6 +1185,22 @@ impl BrowserFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if a file is a valid PE executable by reading its magic bytes (MZ).
|
||||||
|
/// Returns false for archive files (.zip starts with PK, etc.) that were
|
||||||
|
/// incorrectly named with a .exe extension.
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn is_pe_executable(path: &Path) -> bool {
|
||||||
|
use std::io::Read;
|
||||||
|
let Ok(mut file) = std::fs::File::open(path) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let mut magic = [0u8; 2];
|
||||||
|
if file.read_exact(&mut magic).is_err() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
magic == [0x4D, 0x5A] // MZ
|
||||||
|
}
|
||||||
|
|
||||||
// Factory function to create browser instances (kept for backward compatibility)
|
// Factory function to create browser instances (kept for backward compatibility)
|
||||||
pub fn create_browser(browser_type: BrowserType) -> Box<dyn Browser> {
|
pub fn create_browser(browser_type: BrowserType) -> Box<dyn Browser> {
|
||||||
BrowserFactory::instance().create_browser(browser_type)
|
BrowserFactory::instance().create_browser(browser_type)
|
||||||
|
|||||||
@@ -685,7 +685,7 @@ impl BrowserVersionManager {
|
|||||||
"macos-arm64" | "macos-x64" => (format!("wayfern-{version}-{platform_key}.dmg"), true),
|
"macos-arm64" | "macos-x64" => (format!("wayfern-{version}-{platform_key}.dmg"), true),
|
||||||
"linux-x64" | "linux-arm64" => (format!("wayfern-{version}-{platform_key}.tar.xz"), true),
|
"linux-x64" | "linux-arm64" => (format!("wayfern-{version}-{platform_key}.tar.xz"), true),
|
||||||
"windows-x64" | "windows-arm64" => {
|
"windows-x64" | "windows-arm64" => {
|
||||||
(format!("wayfern-{version}-{platform_key}.exe"), false)
|
(format!("wayfern-{version}-{platform_key}.zip"), true)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(
|
return Err(
|
||||||
|
|||||||
Reference in new issue
Block a user