Skip to content

Commit 61d2570

Browse files
committed
[fix] File file refrence in get_app_local_data_dir function
1 parent 0dde40d commit 61d2570

File tree

7 files changed

+36
-6
lines changed

7 files changed

+36
-6
lines changed

src-tauri/Cargo.lock

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ tauri-plugin-context-menu = "0.6.1"
2626
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
2727
dotenv = "0.15.0"
2828
lazy_static = "1.4.0"
29+
strum = { version = "0.25.0", features = ["strum_macros"] }
2930

3031
[features]
3132
# this feature is used for production builds or when `devPath` points to the filesystem

src-tauri/src/libs/filehelper.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ use tauri::Env;
66

77
pub const ENV_FILE: &str = "../.env.local";
88

9-
pub const USERS_FILES: [&str; 4] = ["access_token.db", "auth_code.db", "tasks.json", "user_profile.json"];
10-
119

10+
pub const USERS_FILES: [&str; 4] = ["access_token.db", "auth_code.db", "tasks.json", "user_profile.json"];
1211

1312

1413
pub fn initialize_user_files() {
@@ -32,7 +31,7 @@ pub fn get_app_local_data_dir(file_name: &str) -> String {
3231
let path = path.to_str().unwrap().to_string();
3332
println!("path: {} \n file name: {} \n", path, file_name);
3433
// check if file exists
35-
if !std::path::Path::new(file_name).exists() {
34+
if !std::path::Path::new(&path).exists() {
3635
println!("File does not exist, creating file {} for {}", file_name, path);
3736
// create file
3837
let mut file = std::fs::File::create(&path).unwrap();

src-tauri/src/libs/tauri_actions.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::env;
2+
13
use tauri;
24

35
// super mod imports;
@@ -15,7 +17,7 @@ struct GreetResponse {
1517
pub fn test_command() -> String {
1618
println!("access token path: {}", &*ACCESS_TOKEN_FILE);
1719
println!("ENV_FILE: {}", ENV_FILE);
18-
return "ACCESS_TOKEN_FILE".to_string()
20+
return env::var("DB_PASSWORD").unwrap();
1921
}
2022

2123
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command

src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ import { accessTokenState, activeCategoryTasksState, activeTaskCategoryState, at
99
import Header from "./components/ui/Header";
1010
import { task } from "./types/taskapi";
1111
import { listen_for_auth_code } from "./helpers/eventlistner";
12+
import { test_command } from "./helpers/invoker";
1213

1314
// disable default context menu on build
1415
loadContextmenu();
1516

17+
// to check / test db password
18+
test_command().then(d => pushNotification(d));
19+
1620
function App() {
1721
const [loading, setLoading] = useState<boolean>(false);
1822
const loggedIn = useRecoilValue(loggedInSelector);

src/helpers/invoker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function get_access_token() {
1919
}
2020

2121
export async function test_command() {
22-
return await invoke('test_command');
22+
return await invoke<string>('test_command');
2323
}
2424

2525
export async function greet(name: string) {

src/helpers/windowhelper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Options, isPermissionGranted, requestPermission, sendNotification } from "@tauri-apps/api/notification";
2-
import {showMenu} from "tauri-plugin-context-menu";
2+
import { showMenu } from "tauri-plugin-context-menu";
33

44
// Disable the right-click menu and text selection.
55
export function loadContextmenu() {
@@ -37,3 +37,4 @@ export function pushNotification(options: string | Options) {
3737
});
3838
}
3939

40+

0 commit comments

Comments
 (0)