Skip to content

Commit 66d244b

Browse files
author
CarrotRub
committed
urgent 2.0.1 fixes
1 parent e504fdf commit 66d244b

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

src-tauri/src/settings_initialization.rs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ pub mod settings_creation {
4949
.join("settings")
5050
.join("installation");
5151

52-
let library_settings = base_dirs
53-
.config_dir()
54-
.join("com.fitlauncher.carrotrub")
55-
.join("library");
56-
5752
if !installation_folder_path.exists() {
5853
fs::create_dir_all(&installation_folder_path)
5954
.expect("Failed to create Installation Config directory");
@@ -92,11 +87,48 @@ pub mod settings_creation {
9287
})?;
9388
}
9489

95-
if !library_settings.exists() {
96-
fs::create_dir_all(&library_settings)
90+
let library_settings_dir = base_dirs
91+
.config_dir()
92+
.join("com.fitlauncher.carrotrub")
93+
.join("library");
94+
95+
// Ensure the library directory exists
96+
if !library_settings_dir.exists() {
97+
fs::create_dir_all(&library_settings_dir)
9798
.expect("Failed to create Installation Config directory");
9899
}
99100

101+
// Define paths for specific files/directories within library settings
102+
let downloaded_games_file = library_settings_dir
103+
.join("downloadedGames")
104+
.join("downloaded_games.json");
105+
let collections_dir = library_settings_dir.join("collections");
106+
107+
// Ensure the downloadedGames directory and its file exist
108+
if !downloaded_games_file.parent().unwrap().exists() {
109+
fs::create_dir_all(downloaded_games_file.parent().unwrap())
110+
.expect("Failed to create downloadedGames directory");
111+
}
112+
if !downloaded_games_file.exists() {
113+
let mut file = fs::File::create(downloaded_games_file)
114+
.expect("Failed to create downloaded_games.json file");
115+
file.write_all(b"[]")
116+
.expect("Failed to write to downloaded_games.json file");
117+
} else {
118+
let metadata =
119+
fs::metadata(&downloaded_games_file).expect("Failed to get file metadata");
120+
if metadata.len() == 0 {
121+
// If the file is empty, write "{}"
122+
let mut file = fs::File::create(&downloaded_games_file)
123+
.expect("Failed to open downloaded_games.json file for writing");
124+
file.write_all(b"{}")
125+
.expect("Failed to write to downloaded_games.json file");
126+
}
127+
}
128+
// Ensure the collections directory exists
129+
if !collections_dir.exists() {
130+
fs::create_dir_all(&collections_dir).expect("Failed to create collections directory");
131+
}
100132
Ok(())
101133
}
102134

src-tauri/tauri.conf.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@
5454
],
5555
"enable": true
5656
},
57-
"csp": "script-src 'wasm-unsafe-eval'; connect-src ipc: http://ipc.localhost; asset: http://asset.localhost"
57+
58+
"csp": {
59+
"default-src": "'self' customprotocol: asset: 'unsafe-inline'",
60+
"script-src": "'wasm-unsafe-eval'",
61+
"connect-src": "ipc: http://ipc.localhost http://asset.localhost",
62+
"img-src": "'self' asset: http://asset.localhost blob: data: http: https: *",
63+
"asset-src": "http://asset.localhost"
64+
}
5865
},
5966
"windows": [
6067
{

0 commit comments

Comments
 (0)