Remove failure package (#166)

* Remove dependency on failure

* Update flatpak cargo-lock

* Update cargo version

* Update release manifest
This commit is contained in:
Philip Kristoffersen
2022-06-07 11:53:15 +02:00
committed by GitHub
parent ded52665fe
commit 0385dfb40b
9 changed files with 48 additions and 296 deletions
Generated
+1 -81
View File
@@ -18,15 +18,6 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a13739d7177fbd22bb0ed28badfff9f372f8bef46c863db4e1c6248f6b223b6e" checksum = "a13739d7177fbd22bb0ed28badfff9f372f8bef46c863db4e1c6248f6b223b6e"
[[package]]
name = "addr2line"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
dependencies = [
"gimli",
]
[[package]] [[package]]
name = "adler" name = "adler"
version = "1.0.2" version = "1.0.2"
@@ -107,21 +98,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
version = "0.3.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61"
dependencies = [
"addr2line",
"cc",
"cfg-if 1.0.0",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.13.0" version = "0.13.0"
@@ -148,7 +124,7 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]] [[package]]
name = "boilr" name = "boilr"
version = "1.3.15" version = "1.3.16"
dependencies = [ dependencies = [
"base64", "base64",
"chrono", "chrono",
@@ -157,7 +133,6 @@ dependencies = [
"dashmap", "dashmap",
"eframe", "eframe",
"egui", "egui",
"failure",
"flate2", "flate2",
"futures", "futures",
"image", "image",
@@ -757,28 +732,6 @@ dependencies = [
"threadpool", "threadpool",
] ]
[[package]]
name = "failure"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
dependencies = [
"backtrace",
"failure_derive",
]
[[package]]
name = "failure_derive"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "1.7.0" version = "1.7.0"
@@ -987,12 +940,6 @@ dependencies = [
"weezl", "weezl",
] ]
[[package]]
name = "gimli"
version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4"
[[package]] [[package]]
name = "gl_generator" name = "gl_generator"
version = "0.14.0" version = "0.14.0"
@@ -1775,15 +1722,6 @@ dependencies = [
"objc", "objc",
] ]
[[package]]
name = "object"
version = "0.28.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.10.0" version = "1.10.0"
@@ -2151,12 +2089,6 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2"
[[package]]
name = "rustc-demangle"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]] [[package]]
name = "rusty-leveldb" name = "rusty-leveldb"
version = "0.3.6" version = "0.3.6"
@@ -2475,18 +2407,6 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "synstructure"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
dependencies = [
"proc-macro2",
"quote",
"syn",
"unicode-xid",
]
[[package]] [[package]]
name = "sysinfo" name = "sysinfo"
version = "0.23.12" version = "0.23.12"
+2 -3
View File
@@ -1,14 +1,13 @@
[package] [package]
edition = "2021" edition = "2021"
name = "boilr" name = "boilr"
version = "1.3.15" version = "1.3.16"
[dependencies] [dependencies]
base64 = "^0.13.0" base64 = "^0.13.0"
chrono = "^0.4.19" chrono = "^0.4.19"
config = "^0.11.0" config = "^0.11.0"
copypasta = "0.7.1" copypasta = "^0.7.1"
failure = "^0.1.8"
flate2 = "^1.0.23" flate2 = "^1.0.23"
is_executable = "^1.0.1" is_executable = "^1.0.1"
nom = "^7.1.1" nom = "^7.1.1"
-104
View File
@@ -25,19 +25,6 @@
"dest": "cargo/vendor/ab_glyph_rasterizer-0.1.5", "dest": "cargo/vendor/ab_glyph_rasterizer-0.1.5",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/addr2line/addr2line-0.17.0.crate",
"sha256": "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b",
"dest": "cargo/vendor/addr2line-0.17.0"
},
{
"type": "inline",
"contents": "{\"package\": \"b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b\", \"files\": {}}",
"dest": "cargo/vendor/addr2line-0.17.0",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -168,19 +155,6 @@
"dest": "cargo/vendor/autocfg-1.1.0", "dest": "cargo/vendor/autocfg-1.1.0",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/backtrace/backtrace-0.3.65.crate",
"sha256": "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61",
"dest": "cargo/vendor/backtrace-0.3.65"
},
{
"type": "inline",
"contents": "{\"package\": \"11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61\", \"files\": {}}",
"dest": "cargo/vendor/backtrace-0.3.65",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -974,32 +948,6 @@
"dest": "cargo/vendor/exr-1.4.2", "dest": "cargo/vendor/exr-1.4.2",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/failure/failure-0.1.8.crate",
"sha256": "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86",
"dest": "cargo/vendor/failure-0.1.8"
},
{
"type": "inline",
"contents": "{\"package\": \"d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86\", \"files\": {}}",
"dest": "cargo/vendor/failure-0.1.8",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/failure_derive/failure_derive-0.1.8.crate",
"sha256": "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4",
"dest": "cargo/vendor/failure_derive-0.1.8"
},
{
"type": "inline",
"contents": "{\"package\": \"aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4\", \"files\": {}}",
"dest": "cargo/vendor/failure_derive-0.1.8",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -1273,19 +1221,6 @@
"dest": "cargo/vendor/gif-0.11.3", "dest": "cargo/vendor/gif-0.11.3",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/gimli/gimli-0.26.1.crate",
"sha256": "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4",
"dest": "cargo/vendor/gimli-0.26.1"
},
{
"type": "inline",
"contents": "{\"package\": \"78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4\", \"files\": {}}",
"dest": "cargo/vendor/gimli-0.26.1",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -2313,19 +2248,6 @@
"dest": "cargo/vendor/objc_id-0.1.1", "dest": "cargo/vendor/objc_id-0.1.1",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/object/object-0.28.4.crate",
"sha256": "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424",
"dest": "cargo/vendor/object-0.28.4"
},
{
"type": "inline",
"contents": "{\"package\": \"e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424\", \"files\": {}}",
"dest": "cargo/vendor/object-0.28.4",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -2794,19 +2716,6 @@
"dest": "cargo/vendor/rust-ini-0.13.0", "dest": "cargo/vendor/rust-ini-0.13.0",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/rustc-demangle/rustc-demangle-0.1.21.crate",
"sha256": "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342",
"dest": "cargo/vendor/rustc-demangle-0.1.21"
},
{
"type": "inline",
"contents": "{\"package\": \"7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342\", \"files\": {}}",
"dest": "cargo/vendor/rustc-demangle-0.1.21",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -3249,19 +3158,6 @@
"dest": "cargo/vendor/syn-1.0.94", "dest": "cargo/vendor/syn-1.0.94",
"dest-filename": ".cargo-checksum.json" "dest-filename": ".cargo-checksum.json"
}, },
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/synstructure/synstructure-0.12.6.crate",
"sha256": "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f",
"dest": "cargo/vendor/synstructure-0.12.6"
},
{
"type": "inline",
"contents": "{\"package\": \"f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f\", \"files\": {}}",
"dest": "cargo/vendor/synstructure-0.12.6",
"dest-filename": ".cargo-checksum.json"
},
{ {
"type": "archive", "type": "archive",
"archive-type": "tar-gzip", "archive-type": "tar-gzip",
@@ -25,6 +25,16 @@ https://hughsie.github.io/oars/index.html
--> -->
<content_rating type="oars-1.1" /> <content_rating type="oars-1.1" />
<releases> <releases>
<release version="1.3.16" date="2022-06-07">
<description>
<ul>
<li>Removed dependency on unsafe package failure</li>
</ul>
</description>
</release>
<release version="1.3.14" date="2022-05-30"> <release version="1.3.14" date="2022-05-30">
<description> <description>
<ul> <ul>
+3 -6
View File
@@ -1,9 +1,6 @@
use crate::platform::{Platform, SettingsValidity}; use crate::platform::{Platform, SettingsValidity};
use super::{ use super::{get_egs_manifests, EpicGamesLauncherSettings, ManifestItem};
get_egs_manifests, get_manifests::EpicGamesManifestsError, EpicGamesLauncherSettings,
ManifestItem,
};
pub struct EpicPlatform { pub struct EpicPlatform {
settings: EpicGamesLauncherSettings, settings: EpicGamesLauncherSettings,
@@ -17,7 +14,7 @@ impl EpicPlatform {
} }
} }
impl Platform<ManifestItem, EpicGamesManifestsError> for EpicPlatform { impl Platform<ManifestItem, String> for EpicPlatform {
fn enabled(&self) -> bool { fn enabled(&self) -> bool {
self.settings.enabled self.settings.enabled
} }
@@ -26,7 +23,7 @@ impl Platform<ManifestItem, EpicGamesManifestsError> for EpicPlatform {
"EGS" "EGS"
} }
fn get_shortcuts(&self) -> Result<Vec<ManifestItem>, EpicGamesManifestsError> { fn get_shortcuts(&self) -> Result<Vec<ManifestItem>, String> {
get_egs_manifests(&self.settings) get_egs_manifests(&self.settings)
} }
+6 -20
View File
@@ -4,23 +4,9 @@ use std::fs::{DirEntry, File};
use std::io::BufReader; use std::io::BufReader;
use std::path::Path; 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( pub(crate) fn get_egs_manifests(
settings: &EpicGamesLauncherSettings, settings: &EpicGamesLauncherSettings,
) -> Result<Vec<ManifestItem>, EpicGamesManifestsError> { ) -> Result<Vec<ManifestItem>, String> {
let locations = crate::egs::get_locations(); let locations = crate::egs::get_locations();
match locations { match locations {
Some(locations) => { Some(locations) => {
@@ -83,13 +69,13 @@ pub(crate) fn get_egs_manifests(
} }
Ok(manifests) Ok(manifests)
} }
Err(err) => Err(EpicGamesManifestsError::ReadDirError { Err(err) => Err(format!(
error: err, "Could not read dir at: {:?} error: {:?}",
path: manifest_dir_path.to_string_lossy().to_string(), manifest_dir_path, err
}), )),
} }
} }
None => Err(EpicGamesManifestsError::NotFound), None => Err("Manifests not found".to_string()),
} }
} }
+10 -35
View File
@@ -1,4 +1,3 @@
use failure::*;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use crate::{gog::gog_config::GogConfig, platform::Platform}; use crate::{gog::gog_config::GogConfig, platform::Platform};
@@ -15,7 +14,7 @@ pub struct GogPlatform {
pub fn get_shortcuts_from_config( pub fn get_shortcuts_from_config(
_wine_c_drive: Option<String>, _wine_c_drive: Option<String>,
config_path: PathBuf, config_path: PathBuf,
) -> Result<Vec<GogShortcut>, GogErrors> { ) -> Result<Vec<GogShortcut>, String> {
let install_locations = get_install_locations(config_path)?; let install_locations = get_install_locations(config_path)?;
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
let install_locations = if let Some(wine_c_drive) = &_wine_c_drive { 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 games
} }
impl Platform<GogShortcut, GogErrors> for GogPlatform { impl Platform<GogShortcut, String> for GogPlatform {
fn enabled(&self) -> bool { fn enabled(&self) -> bool {
self.settings.enabled self.settings.enabled
} }
@@ -152,7 +151,7 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
self.settings.create_symlinks self.settings.create_symlinks
} }
fn get_shortcuts(&self) -> Result<Vec<GogShortcut>, GogErrors> { fn get_shortcuts(&self) -> Result<Vec<GogShortcut>, String> {
let gog_location = self let gog_location = self
.settings .settings
.location .location
@@ -160,11 +159,11 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
.map(|location| Path::new(&location).to_path_buf()) .map(|location| Path::new(&location).to_path_buf())
.unwrap_or_else(default_location); .unwrap_or_else(default_location);
if !gog_location.exists() { 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"); let config_path = gog_location.join("config.json");
if !config_path.exists() { 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) 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() .collect()
} }
fn get_install_locations(path: PathBuf) -> Result<Vec<String>, GogErrors> { fn get_install_locations(path: PathBuf) -> Result<Vec<String>, String> {
let data_res = let data_res = std::fs::read_to_string(&path)
std::fs::read_to_string(&path).map_err(|e| GogErrors::ConfigFileCouldNotBeRead { .map_err(|e| format!("Config file not read {:?} , error: {:?} ", path.clone(), e))?;
path: path.clone(), let config: GogConfig = serde_json::from_str(&data_res)
error: format!("{}", e), .map_err(|e| format!("Config file not read {:?} , error: {:?} ", path.clone(), e))?;
})?;
let config: GogConfig =
serde_json::from_str(&data_res).map_err(|e| GogErrors::ConfigFileCouldNotBeRead {
path,
error: format!("{}", e),
})?;
let path_vec = match config.library_path { let path_vec = match config.library_path {
Some(path) => vec![path], Some(path) => vec![path],
None => vec![], None => vec![],
@@ -234,21 +227,3 @@ pub fn default_location() -> PathBuf {
Path::new(&home).join("Games/gog-galaxy/drive_c/ProgramData/GOG.com/Galaxy") 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 },
}
+8 -22
View File
@@ -2,7 +2,6 @@ use super::butler_db_parser::*;
use super::receipt::Receipt; use super::receipt::Receipt;
use super::{ItchGame, ItchSettings}; use super::{ItchGame, ItchSettings};
use crate::platform::{Platform, SettingsValidity}; use crate::platform::{Platform, SettingsValidity};
use failure::*;
use flate2::read::GzDecoder; use flate2::read::GzDecoder;
use is_executable::IsExecutable; use is_executable::IsExecutable;
use std::collections::HashSet; 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 { fn enabled(&self) -> bool {
self.settings.enabled self.settings.enabled
} }
@@ -28,25 +27,24 @@ impl Platform<ItchGame, ItchErrors> for ItchPlatform {
"Itch" "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 = self.settings.location.clone();
let itch_location = itch_location.unwrap_or_else(get_default_location); 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"); let itch_db_location = Path::new(&itch_location).join("db").join("butler.db-wal");
if !itch_db_location.exists() { if !itch_db_location.exists() {
return Err(ItchErrors::PathNotFound { return Err(format!("Path not found: {:?}", itch_db_location.to_str()));
path: itch_db_location.to_str().unwrap().to_string(),
});
} }
let shortcut_bytes = std::fs::read(&itch_db_location).unwrap(); let shortcut_bytes = std::fs::read(&itch_db_location).unwrap();
let paths = match parse_butler_db(&shortcut_bytes) { let paths = match parse_butler_db(&shortcut_bytes) {
Ok((_, shortcuts)) => Ok(shortcuts), Ok((_, shortcuts)) => Ok(shortcuts),
Err(e) => Err(ItchErrors::ParseError { Err(e) => Err(format!(
error: e.to_string(), "Could not parse path: {:?} , error: {:?}",
path: itch_db_location.to_str().unwrap().to_string(), itch_db_location.to_str(),
}), e
)),
}?; }?;
//This is done to paths dedupe //This is done to paths dedupe
@@ -129,15 +127,3 @@ pub fn get_default_location() -> String {
.to_string() .to_string()
//C:\Users\phili\AppData\Local\itch //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 },
}
+8 -25
View File
@@ -1,5 +1,4 @@
use crate::platform::{Platform, SettingsValidity}; use crate::platform::{Platform, SettingsValidity};
use failure::*;
use nom::bytes::complete::take_until; use nom::bytes::complete::take_until;
use std::{ use std::{
fs::DirEntry, fs::DirEntry,
@@ -12,7 +11,7 @@ pub struct OriginPlatform {
pub settings: OriginSettings, pub settings: OriginSettings,
} }
impl Platform<OriginGame, OriginErrors> for OriginPlatform { impl Platform<OriginGame, String> for OriginPlatform {
fn enabled(&self) -> bool { fn enabled(&self) -> bool {
self.settings.enabled self.settings.enabled
} }
@@ -26,21 +25,20 @@ impl Platform<OriginGame, OriginErrors> for OriginPlatform {
false false
} }
fn get_shortcuts(&self) -> Result<Vec<OriginGame>, OriginErrors> { fn get_shortcuts(&self) -> Result<Vec<OriginGame>, String> {
let origin_folders = get_default_locations(); let origin_folders = get_default_locations();
if origin_folders.is_none() { if origin_folders.is_none() {
return Err(OriginErrors::PathNotFound { return Err(String::from("Default path not found"));
path: "Default path".to_string(),
});
} }
let origin_folders = origin_folders.unwrap(); let origin_folders = origin_folders.unwrap();
let origin_folder = origin_folders.local_content_path; let origin_folder = origin_folders.local_content_path;
let origin_exe = origin_folders.exe_path; let origin_exe = origin_folders.exe_path;
let game_folders = origin_folder.join("LocalContent").read_dir().map_err(|e| { let game_folders = origin_folder.join("LocalContent").read_dir().map_err(|e| {
OriginErrors::CouldNotReadGameDir { format!(
path: origin_folder.join("LocalContent"), "Could not read game dir: {} , error: {:?}",
error: format!("{:?}", e), origin_folder.join("LocalContent").to_string_lossy(),
} e
)
})?; })?;
let games = game_folders let games = game_folders
.filter_map(|folder| folder.ok()) .filter_map(|folder| folder.ok())
@@ -202,18 +200,3 @@ fn get_exe_path() -> Option<PathBuf> {
} }
None 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 },
}