mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
@@ -2,6 +2,9 @@
|
||||
#![deny(clippy::get_unwrap)]
|
||||
#![deny(clippy::unwrap_used)]
|
||||
#![deny(clippy::indexing_slicing)]
|
||||
#![deny(clippy::expect_used)]
|
||||
#![deny(clippy::panic)]
|
||||
#![deny(clippy::todo)]
|
||||
|
||||
mod config;
|
||||
mod migration;
|
||||
|
||||
@@ -214,12 +214,12 @@ pub fn default_location() -> PathBuf {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let key = "PROGRAMDATA";
|
||||
let program_data = std::env::var(key).expect("Expected a APPDATA variable to be defined");
|
||||
let program_data = std::env::var(key).unwrap_or_default();
|
||||
Path::new(&program_data).join("GOG.com").join("Galaxy")
|
||||
}
|
||||
#[cfg(target_family = "unix")]
|
||||
{
|
||||
let home = std::env::var("HOME").expect("Expected a home variable to be defined");
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
Path::new(&home).join("Games/gog-galaxy/drive_c/ProgramData/GOG.com/Galaxy")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ fn dbpath_to_game(paths: &DbPaths) -> Option<ItchGame> {
|
||||
#[cfg(target_family = "unix")]
|
||||
pub fn get_default_location() -> String {
|
||||
//If we don't have a home drive we have to just die
|
||||
let home = std::env::var("HOME").expect("Expected a home variable to be defined");
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
format!("{}/.config/itch/", home)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,7 @@ impl ActualSteamCollection {
|
||||
let key = format!("user-collections.{}", name_to_key(name));
|
||||
let value = serialize_collection_value(name, ids);
|
||||
let start = SystemTime::now();
|
||||
let since_the_epoch = start
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.expect("Time went backwards");
|
||||
let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap_or_default();
|
||||
let timestamp = since_the_epoch.as_secs();
|
||||
|
||||
ActualSteamCollection {
|
||||
@@ -129,8 +127,10 @@ pub fn write_collections<S: AsRef<str>>(
|
||||
save_category(category_key, collections, &mut write_batch)?;
|
||||
|
||||
if let Some(path) = get_vdf_path(steam_user_id) {
|
||||
let content = std::fs::read_to_string(&path).expect("Should be able to read this file");
|
||||
if let Some(mut vdf_collections) = parse_vdf_collection(content) {
|
||||
let content = std::fs::read_to_string(&path)
|
||||
.ok()
|
||||
.and_then(parse_vdf_collection);
|
||||
if let Some(mut vdf_collections) = content {
|
||||
let boilr_keys: Vec<String> = vdf_collections
|
||||
.keys()
|
||||
.filter(|k| k.contains(BOILR_TAG))
|
||||
@@ -320,7 +320,7 @@ fn get_level_db_location() -> Option<PathBuf> {
|
||||
|
||||
fn serialize_collection_value<S: AsRef<str>>(name: S, game_ids: &[usize]) -> String {
|
||||
let value = ValueCollection::new(name, game_ids);
|
||||
serde_json::to_string(&value).expect("Should be able to serialize known type")
|
||||
serde_json::to_string(&value).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn name_to_key<S: AsRef<str>>(name: S) -> String {
|
||||
@@ -360,7 +360,7 @@ pub fn write_vdf_collection_to_string<S: AsRef<str>>(
|
||||
vdf: &HashMap<String, VdfCollection>,
|
||||
) -> Option<String> {
|
||||
let input = input.as_ref();
|
||||
let str = serde_json::to_string(vdf).expect("Should be able to serialize known type");
|
||||
if let Ok(str) = serde_json::to_string(vdf) {
|
||||
let encoded_json = format!("\"{}\"", str.replace('\\', "\\\""));
|
||||
let key = "\t\"user-collections\"\t\t";
|
||||
if let Some(start_index) = input.find_substring(key) {
|
||||
@@ -371,16 +371,12 @@ pub fn write_vdf_collection_to_string<S: AsRef<str>>(
|
||||
input.get(..start_index_plus_key),
|
||||
input.get(end_index_in_full..),
|
||||
) {
|
||||
let result = format!(
|
||||
"{}{}{}",
|
||||
before,
|
||||
encoded_json,
|
||||
after
|
||||
);
|
||||
let result = format!("{}{}{}", before, encoded_json, after);
|
||||
return Some(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ pub fn get_shortcuts_paths(settings: &SteamSettings) -> eyre::Result<Vec<SteamUs
|
||||
let folder_path = folder.path();
|
||||
let folder_str = folder_path
|
||||
.to_str()
|
||||
.expect("We just checked that this was there");
|
||||
.unwrap_or_default();
|
||||
let path = format!("{}//config//shortcuts.vdf", folder_str);
|
||||
let shortcuts_path = Path::new(path.as_str());
|
||||
let folder_string = folder_str.to_string();
|
||||
|
||||
Reference in New Issue
Block a user