Used std::process::Output on DXVK applying instead of String

This fixes errors related to UTF-8 decoding since different systems may have
different default encodings
This commit is contained in:
Observer KRypt0n_ 2022-08-05 23:22:42 +02:00
parent 5e2bac1a3f
commit a1cdf81eca
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
4 changed files with 9 additions and 8 deletions

View file

@ -1,6 +1,7 @@
use serde::{Serialize, Deserialize};
use std::io::{Error, ErrorKind};
use std::process::{Command, Output};
use lazy_static::lazy_static;
use regex::Regex;
@ -69,7 +70,7 @@ impl Version {
std::path::Path::new(&format!("{}/{}", folder.to_string(), self.name)).exists()
}
pub fn apply<T: ToString>(&self, dxvks_folder: T, prefix_path: T) -> std::io::Result<String> {
pub fn apply<T: ToString>(&self, dxvks_folder: T, prefix_path: T) -> std::io::Result<Output> {
let apply_path = format!("{}/{}/setup_dxvk.sh", dxvks_folder.to_string(), self.name);
let config = config::get()?;
@ -102,7 +103,7 @@ impl Version {
std::fs::write(&apply_path, apply_script)?;
let output = std::process::Command::new("bash")
let output = Command::new("bash")
.arg(&apply_path)
.arg("install")
.env("WINEARCH", "win64")
@ -111,7 +112,7 @@ impl Version {
.output()?;
if output.status.success() {
Ok(String::from_utf8(output.stdout).unwrap())
Ok(output)
}
else {

View file

@ -71,7 +71,7 @@ impl DxvkRow {
}
}
pub fn apply<T: ToString>(&self, dxvks_folder: T, prefix_path: T) -> std::io::Result<String> {
pub fn apply<T: ToString>(&self, dxvks_folder: T, prefix_path: T) -> std::io::Result<std::process::Output> {
self.button.set_sensitive(false);
self.apply_button.set_sensitive(false);

View file

@ -323,7 +323,7 @@ impl App {
// Apply DXVK
match dxvk_version.apply(&config.game.dxvk.builds, &config.game.wine.prefix) {
Ok(output) => {
println!("Applied DXVK:\n\n{output}");
println!("Applied DXVK:\n\n{}", String::from_utf8_lossy(&output.stdout));
// Update dxvk config
config.game.dxvk.selected = Some(dxvk_version.name.clone());

View file

@ -308,7 +308,7 @@ impl App {
let config = config::get().expect("Failed to load config");
match component.apply(&config.game.dxvk.builds, &config.game.wine.prefix) {
Ok(output) => println!("{}", output),
Ok(output) => println!("{}", String::from_utf8_lossy(&output.stdout)),
Err(err) => {
this.update(Actions::Toast(Rc::new((
String::from("Failed to apply DXVK"), err
@ -417,7 +417,7 @@ impl App {
if let Ok(awaiter) = component.download(&config.game.dxvk.builds) {
awaiter.then(clone!(@strong this => move |_| {
match component.apply(&config.game.dxvk.builds, &config.game.wine.prefix) {
Ok(output) => println!("{}", output),
Ok(output) => println!("{}", String::from_utf8_lossy(&output.stdout)),
Err(err) => {
this.update(Actions::Toast(Rc::new((
String::from("Failed to apply DXVK"), err
@ -513,7 +513,7 @@ impl App {
std::thread::spawn(clone!(@strong config, @strong this => move || {
match version.apply(&config.game.dxvk.builds, &config.game.wine.prefix) {
Ok(output) => println!("{}", output),
Ok(output) => println!("{}", String::from_utf8_lossy(&output.stdout)),
Err(err) => {
this.update(Actions::Toast(Rc::new((
String::from("Failed to apply DXVK"), err