mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Remove failure package (#166)
* Remove dependency on failure * Update flatpak cargo-lock * Update cargo version * Update release manifest
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
use crate::platform::{Platform, SettingsValidity};
|
||||
|
||||
use super::{
|
||||
get_egs_manifests, get_manifests::EpicGamesManifestsError, EpicGamesLauncherSettings,
|
||||
ManifestItem,
|
||||
};
|
||||
use super::{get_egs_manifests, EpicGamesLauncherSettings, ManifestItem};
|
||||
|
||||
pub struct EpicPlatform {
|
||||
settings: EpicGamesLauncherSettings,
|
||||
@@ -17,7 +14,7 @@ impl EpicPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
impl Platform<ManifestItem, EpicGamesManifestsError> for EpicPlatform {
|
||||
impl Platform<ManifestItem, String> for EpicPlatform {
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
@@ -26,7 +23,7 @@ impl Platform<ManifestItem, EpicGamesManifestsError> for EpicPlatform {
|
||||
"EGS"
|
||||
}
|
||||
|
||||
fn get_shortcuts(&self) -> Result<Vec<ManifestItem>, EpicGamesManifestsError> {
|
||||
fn get_shortcuts(&self) -> Result<Vec<ManifestItem>, String> {
|
||||
get_egs_manifests(&self.settings)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,9 @@ use std::fs::{DirEntry, File};
|
||||
use std::io::BufReader;
|
||||
use std::path::Path;
|
||||
|
||||
use failure::*;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum EpicGamesManifestsError {
|
||||
#[fail(display = "EpicGamesLauncher not found")]
|
||||
NotFound,
|
||||
|
||||
#[fail(
|
||||
display = "Could not read EpicGamesLauncher manifest directory at {} error: {}",
|
||||
path, error
|
||||
)]
|
||||
ReadDirError { path: String, error: std::io::Error },
|
||||
}
|
||||
|
||||
pub(crate) fn get_egs_manifests(
|
||||
settings: &EpicGamesLauncherSettings,
|
||||
) -> Result<Vec<ManifestItem>, EpicGamesManifestsError> {
|
||||
) -> Result<Vec<ManifestItem>, String> {
|
||||
let locations = crate::egs::get_locations();
|
||||
match locations {
|
||||
Some(locations) => {
|
||||
@@ -83,13 +69,13 @@ pub(crate) fn get_egs_manifests(
|
||||
}
|
||||
Ok(manifests)
|
||||
}
|
||||
Err(err) => Err(EpicGamesManifestsError::ReadDirError {
|
||||
error: err,
|
||||
path: manifest_dir_path.to_string_lossy().to_string(),
|
||||
}),
|
||||
Err(err) => Err(format!(
|
||||
"Could not read dir at: {:?} error: {:?}",
|
||||
manifest_dir_path, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
None => Err(EpicGamesManifestsError::NotFound),
|
||||
None => Err("Manifests not found".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-35
@@ -1,4 +1,3 @@
|
||||
use failure::*;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::{gog::gog_config::GogConfig, platform::Platform};
|
||||
@@ -15,7 +14,7 @@ pub struct GogPlatform {
|
||||
pub fn get_shortcuts_from_config(
|
||||
_wine_c_drive: Option<String>,
|
||||
config_path: PathBuf,
|
||||
) -> Result<Vec<GogShortcut>, GogErrors> {
|
||||
) -> Result<Vec<GogShortcut>, String> {
|
||||
let install_locations = get_install_locations(config_path)?;
|
||||
#[cfg(target_family = "unix")]
|
||||
let install_locations = if let Some(wine_c_drive) = &_wine_c_drive {
|
||||
@@ -138,7 +137,7 @@ fn get_games_from_game_folders(game_folders: Vec<PathBuf>) -> Vec<(GogGame, Path
|
||||
games
|
||||
}
|
||||
|
||||
impl Platform<GogShortcut, GogErrors> for GogPlatform {
|
||||
impl Platform<GogShortcut, String> for GogPlatform {
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
@@ -152,7 +151,7 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
|
||||
self.settings.create_symlinks
|
||||
}
|
||||
|
||||
fn get_shortcuts(&self) -> Result<Vec<GogShortcut>, GogErrors> {
|
||||
fn get_shortcuts(&self) -> Result<Vec<GogShortcut>, String> {
|
||||
let gog_location = self
|
||||
.settings
|
||||
.location
|
||||
@@ -160,11 +159,11 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
|
||||
.map(|location| Path::new(&location).to_path_buf())
|
||||
.unwrap_or_else(default_location);
|
||||
if !gog_location.exists() {
|
||||
return Err(GogErrors::PathNotFound { path: gog_location });
|
||||
return Err(format!("Could not find path: {:?}", gog_location));
|
||||
}
|
||||
let config_path = gog_location.join("config.json");
|
||||
if !config_path.exists() {
|
||||
return Err(GogErrors::ConfigFileNotFound { path: config_path });
|
||||
return Err(format!("Config file not found: {:?}", config_path));
|
||||
}
|
||||
get_shortcuts_from_config(self.settings.wine_c_drive.clone(), config_path)
|
||||
}
|
||||
@@ -203,17 +202,11 @@ fn fix_paths(wine_c_drive: &str, paths: Vec<String>) -> Vec<String> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn get_install_locations(path: PathBuf) -> Result<Vec<String>, GogErrors> {
|
||||
let data_res =
|
||||
std::fs::read_to_string(&path).map_err(|e| GogErrors::ConfigFileCouldNotBeRead {
|
||||
path: path.clone(),
|
||||
error: format!("{}", e),
|
||||
})?;
|
||||
let config: GogConfig =
|
||||
serde_json::from_str(&data_res).map_err(|e| GogErrors::ConfigFileCouldNotBeRead {
|
||||
path,
|
||||
error: format!("{}", e),
|
||||
})?;
|
||||
fn get_install_locations(path: PathBuf) -> Result<Vec<String>, String> {
|
||||
let data_res = std::fs::read_to_string(&path)
|
||||
.map_err(|e| format!("Config file not read {:?} , error: {:?} ", path.clone(), e))?;
|
||||
let config: GogConfig = serde_json::from_str(&data_res)
|
||||
.map_err(|e| format!("Config file not read {:?} , error: {:?} ", path.clone(), e))?;
|
||||
let path_vec = match config.library_path {
|
||||
Some(path) => vec![path],
|
||||
None => vec![],
|
||||
@@ -234,21 +227,3 @@ pub fn default_location() -> PathBuf {
|
||||
Path::new(&home).join("Games/gog-galaxy/drive_c/ProgramData/GOG.com/Galaxy")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum GogErrors {
|
||||
#[fail(
|
||||
display = "Gog path: {:?} could not be found. Try to specify a different path for Gog.",
|
||||
path
|
||||
)]
|
||||
PathNotFound { path: PathBuf },
|
||||
|
||||
#[fail(display = "Gog config file not found at path: {:?}", path)]
|
||||
ConfigFileNotFound { path: PathBuf },
|
||||
|
||||
#[fail(
|
||||
display = "Gog config file at path: {:?} could not be red {}",
|
||||
path, error
|
||||
)]
|
||||
ConfigFileCouldNotBeRead { path: PathBuf, error: String },
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ use super::butler_db_parser::*;
|
||||
use super::receipt::Receipt;
|
||||
use super::{ItchGame, ItchSettings};
|
||||
use crate::platform::{Platform, SettingsValidity};
|
||||
use failure::*;
|
||||
use flate2::read::GzDecoder;
|
||||
use is_executable::IsExecutable;
|
||||
use std::collections::HashSet;
|
||||
@@ -19,7 +18,7 @@ impl ItchPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
impl Platform<ItchGame, ItchErrors> for ItchPlatform {
|
||||
impl Platform<ItchGame, String> for ItchPlatform {
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
@@ -28,25 +27,24 @@ impl Platform<ItchGame, ItchErrors> for ItchPlatform {
|
||||
"Itch"
|
||||
}
|
||||
|
||||
fn get_shortcuts(&self) -> Result<Vec<ItchGame>, ItchErrors> {
|
||||
fn get_shortcuts(&self) -> Result<Vec<ItchGame>, String> {
|
||||
let itch_location = self.settings.location.clone();
|
||||
let itch_location = itch_location.unwrap_or_else(get_default_location);
|
||||
|
||||
let itch_db_location = Path::new(&itch_location).join("db").join("butler.db-wal");
|
||||
if !itch_db_location.exists() {
|
||||
return Err(ItchErrors::PathNotFound {
|
||||
path: itch_db_location.to_str().unwrap().to_string(),
|
||||
});
|
||||
return Err(format!("Path not found: {:?}", itch_db_location.to_str()));
|
||||
}
|
||||
|
||||
let shortcut_bytes = std::fs::read(&itch_db_location).unwrap();
|
||||
|
||||
let paths = match parse_butler_db(&shortcut_bytes) {
|
||||
Ok((_, shortcuts)) => Ok(shortcuts),
|
||||
Err(e) => Err(ItchErrors::ParseError {
|
||||
error: e.to_string(),
|
||||
path: itch_db_location.to_str().unwrap().to_string(),
|
||||
}),
|
||||
Err(e) => Err(format!(
|
||||
"Could not parse path: {:?} , error: {:?}",
|
||||
itch_db_location.to_str(),
|
||||
e
|
||||
)),
|
||||
}?;
|
||||
|
||||
//This is done to paths dedupe
|
||||
@@ -129,15 +127,3 @@ pub fn get_default_location() -> String {
|
||||
.to_string()
|
||||
//C:\Users\phili\AppData\Local\itch
|
||||
}
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum ItchErrors {
|
||||
#[fail(
|
||||
display = "Itch path: {} could not be found. Try to specify a different path for the Itch.",
|
||||
path
|
||||
)]
|
||||
PathNotFound { path: String },
|
||||
|
||||
#[fail(display = "Could not parse Itch db at {} error: {}", path, error)]
|
||||
ParseError { path: String, error: String },
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use crate::platform::{Platform, SettingsValidity};
|
||||
use failure::*;
|
||||
use nom::bytes::complete::take_until;
|
||||
use std::{
|
||||
fs::DirEntry,
|
||||
@@ -12,7 +11,7 @@ pub struct OriginPlatform {
|
||||
pub settings: OriginSettings,
|
||||
}
|
||||
|
||||
impl Platform<OriginGame, OriginErrors> for OriginPlatform {
|
||||
impl Platform<OriginGame, String> for OriginPlatform {
|
||||
fn enabled(&self) -> bool {
|
||||
self.settings.enabled
|
||||
}
|
||||
@@ -26,21 +25,20 @@ impl Platform<OriginGame, OriginErrors> for OriginPlatform {
|
||||
false
|
||||
}
|
||||
|
||||
fn get_shortcuts(&self) -> Result<Vec<OriginGame>, OriginErrors> {
|
||||
fn get_shortcuts(&self) -> Result<Vec<OriginGame>, String> {
|
||||
let origin_folders = get_default_locations();
|
||||
if origin_folders.is_none() {
|
||||
return Err(OriginErrors::PathNotFound {
|
||||
path: "Default path".to_string(),
|
||||
});
|
||||
return Err(String::from("Default path not found"));
|
||||
}
|
||||
let origin_folders = origin_folders.unwrap();
|
||||
let origin_folder = origin_folders.local_content_path;
|
||||
let origin_exe = origin_folders.exe_path;
|
||||
let game_folders = origin_folder.join("LocalContent").read_dir().map_err(|e| {
|
||||
OriginErrors::CouldNotReadGameDir {
|
||||
path: origin_folder.join("LocalContent"),
|
||||
error: format!("{:?}", e),
|
||||
}
|
||||
format!(
|
||||
"Could not read game dir: {} , error: {:?}",
|
||||
origin_folder.join("LocalContent").to_string_lossy(),
|
||||
e
|
||||
)
|
||||
})?;
|
||||
let games = game_folders
|
||||
.filter_map(|folder| folder.ok())
|
||||
@@ -202,18 +200,3 @@ fn get_exe_path() -> Option<PathBuf> {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum OriginErrors {
|
||||
#[fail(
|
||||
display = "Origin path: {} could not be found. Try to specify a different path for Origin.",
|
||||
path
|
||||
)]
|
||||
PathNotFound { path: String },
|
||||
|
||||
#[fail(
|
||||
display = "Could not read Origin directory: {:?}. Error: {}",
|
||||
path, error
|
||||
)]
|
||||
CouldNotReadGameDir { path: PathBuf, error: String },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user