Skip to content

Commit

Permalink
Add permissions for fs and create config dir if it doesn't exist (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzania authored Oct 4, 2023
1 parent 155f532 commit 96a6be1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ x25519-dalek = { version = "2", features = [
] }
prost = "0.11"

tauri = { version = "1.4.1", features = [ "http-all", "window-all", "system-tray", "devtools"] }
# FIXME: Remove devtools before release
tauri = { version = "1.4.1", features = [ "http-all", "window-all", "system-tray", "devtools", "fs-all", "path-all"] }
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
local-ip-address = "0.5.5"
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ pub async fn init_db(app_handle: &AppHandle) -> Result<DbPool, Error> {
.path_resolver()
.app_data_dir()
.ok_or(Error::Config)?;
// Create app data directory if it doesnt exist
debug!("Creating app data dir at: {}", app_dir.to_string_lossy());
fs::create_dir_all(&app_dir)?;
info!("Created app data dir at: {}", app_dir.to_string_lossy());
let db_path = app_dir.join(DB_NAME);
if !db_path.exists() {
debug!(
Expand Down
18 changes: 17 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@
"iconPath": "icons/32x32.png",
"iconAsTemplate": false
},

"allowlist": {
"all": false,
"path": {
"all": true
},
"fs": {
"all": true,
"readFile": true,
"writeFile": true,
"readDir": true,
"copyFile": true,
"createDir": true,
"removeDir": true,
"removeFile": true,
"renameFile": true,
"exists": true
},
"window": {
"all": true
},
"http": {
"all": true,
"all": true,
"request": true,
"scope": ["https://**", "http://**"]
}
Expand Down

0 comments on commit 96a6be1

Please sign in to comment.