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::get_unwrap)]
|
||||||
#![deny(clippy::unwrap_used)]
|
#![deny(clippy::unwrap_used)]
|
||||||
#![deny(clippy::indexing_slicing)]
|
#![deny(clippy::indexing_slicing)]
|
||||||
|
#![deny(clippy::expect_used)]
|
||||||
|
#![deny(clippy::panic)]
|
||||||
|
#![deny(clippy::todo)]
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod migration;
|
mod migration;
|
||||||
|
|||||||
@@ -214,12 +214,12 @@ pub fn default_location() -> PathBuf {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
let key = "PROGRAMDATA";
|
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")
|
Path::new(&program_data).join("GOG.com").join("Galaxy")
|
||||||
}
|
}
|
||||||
#[cfg(target_family = "unix")]
|
#[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")
|
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")]
|
#[cfg(target_family = "unix")]
|
||||||
pub fn get_default_location() -> String {
|
pub fn get_default_location() -> String {
|
||||||
//If we don't have a home drive we have to just die
|
//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)
|
format!("{}/.config/itch/", home)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-24
@@ -47,9 +47,7 @@ impl ActualSteamCollection {
|
|||||||
let key = format!("user-collections.{}", name_to_key(name));
|
let key = format!("user-collections.{}", name_to_key(name));
|
||||||
let value = serialize_collection_value(name, ids);
|
let value = serialize_collection_value(name, ids);
|
||||||
let start = SystemTime::now();
|
let start = SystemTime::now();
|
||||||
let since_the_epoch = start
|
let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap_or_default();
|
||||||
.duration_since(UNIX_EPOCH)
|
|
||||||
.expect("Time went backwards");
|
|
||||||
let timestamp = since_the_epoch.as_secs();
|
let timestamp = since_the_epoch.as_secs();
|
||||||
|
|
||||||
ActualSteamCollection {
|
ActualSteamCollection {
|
||||||
@@ -129,8 +127,10 @@ pub fn write_collections<S: AsRef<str>>(
|
|||||||
save_category(category_key, collections, &mut write_batch)?;
|
save_category(category_key, collections, &mut write_batch)?;
|
||||||
|
|
||||||
if let Some(path) = get_vdf_path(steam_user_id) {
|
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");
|
let content = std::fs::read_to_string(&path)
|
||||||
if let Some(mut vdf_collections) = parse_vdf_collection(content) {
|
.ok()
|
||||||
|
.and_then(parse_vdf_collection);
|
||||||
|
if let Some(mut vdf_collections) = content {
|
||||||
let boilr_keys: Vec<String> = vdf_collections
|
let boilr_keys: Vec<String> = vdf_collections
|
||||||
.keys()
|
.keys()
|
||||||
.filter(|k| k.contains(BOILR_TAG))
|
.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 {
|
fn serialize_collection_value<S: AsRef<str>>(name: S, game_ids: &[usize]) -> String {
|
||||||
let value = ValueCollection::new(name, game_ids);
|
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 {
|
fn name_to_key<S: AsRef<str>>(name: S) -> String {
|
||||||
@@ -360,24 +360,20 @@ pub fn write_vdf_collection_to_string<S: AsRef<str>>(
|
|||||||
vdf: &HashMap<String, VdfCollection>,
|
vdf: &HashMap<String, VdfCollection>,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
let input = input.as_ref();
|
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 encoded_json = format!("\"{}\"", str.replace('\\', "\\\""));
|
||||||
let key = "\t\"user-collections\"\t\t";
|
let key = "\t\"user-collections\"\t\t";
|
||||||
if let Some(start_index) = input.find_substring(key) {
|
if let Some(start_index) = input.find_substring(key) {
|
||||||
let start_index_plus_key = start_index + key.len();
|
let start_index_plus_key = start_index + key.len();
|
||||||
if let Some(line_index) = input.get(start_index_plus_key..).and_then(|i| i.find('\n')) {
|
if let Some(line_index) = input.get(start_index_plus_key..).and_then(|i| i.find('\n')) {
|
||||||
let end_index_in_full = line_index + start_index_plus_key;
|
let end_index_in_full = line_index + start_index_plus_key;
|
||||||
if let (Some(before), Some(after)) = (
|
if let (Some(before), Some(after)) = (
|
||||||
input.get(..start_index_plus_key),
|
input.get(..start_index_plus_key),
|
||||||
input.get(end_index_in_full..),
|
input.get(end_index_in_full..),
|
||||||
) {
|
) {
|
||||||
let result = format!(
|
let result = format!("{}{}{}", before, encoded_json, after);
|
||||||
"{}{}{}",
|
return Some(result);
|
||||||
before,
|
}
|
||||||
encoded_json,
|
|
||||||
after
|
|
||||||
);
|
|
||||||
return Some(result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ pub fn get_shortcuts_paths(settings: &SteamSettings) -> eyre::Result<Vec<SteamUs
|
|||||||
let folder_path = folder.path();
|
let folder_path = folder.path();
|
||||||
let folder_str = folder_path
|
let folder_str = folder_path
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect("We just checked that this was there");
|
.unwrap_or_default();
|
||||||
let path = format!("{}//config//shortcuts.vdf", folder_str);
|
let path = format!("{}//config//shortcuts.vdf", folder_str);
|
||||||
let shortcuts_path = Path::new(path.as_str());
|
let shortcuts_path = Path::new(path.as_str());
|
||||||
let folder_string = folder_str.to_string();
|
let folder_string = folder_str.to_string();
|
||||||
|
|||||||
Reference in New Issue
Block a user