From 9cf7b1b0f2f1b372124374c22449e530980d07a3 Mon Sep 17 00:00:00 2001 From: Danil Date: Sun, 23 Jun 2024 20:24:15 +0700 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B8=D0=BB=D1=8F=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build.yaml | 11 ++++++----- src-tauri/Cargo.lock | 7 ------- src-tauri/Cargo.toml | 4 ++-- src-tauri/src/main.rs | 3 +-- src-tauri/src/tasks_functions.rs | 10 ++++++---- src-tauri/tauri.conf.json | 8 +------- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index e2e8827..9d50fcd 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -36,18 +36,19 @@ jobs: with: lfs: true token: ${{secrets.RELEASE_TOKEN}} + - name: Check repository run: | - touch src-tauri/.env - echo 'ENC_KEY=${{secrets.HASH_KEY}}' > src-tauri/.env + touch src-tauri/src/config.rs + echo 'pub(crate) static ENC_KEY: &str = "${{secrets.HASH_KEY}}";' > src-tauri/src/config.rs - name: Get files (Linux) if: matrix.platform == 'ubuntu-latest' run: | - ls -l src-tauri - cat src-tauri/.env + ls -l src-tauri/src - name: Get files (Windows) if: matrix.platform == 'windows-latest' - run: dir src-tauri + run: dir src-tauri/src + - name: Install Rust stable uses: dtolnay/rust-toolchain@stable with: diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index bee247f..b57943f 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -681,12 +681,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "dotenv" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" - [[package]] name = "dtoa" version = "1.0.9" @@ -3206,7 +3200,6 @@ dependencies = [ name = "to-do-app" version = "0.0.0" dependencies = [ - "dotenv", "magic-crypt", "rust-fuzzy-search", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d436055..88b9afc 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -16,7 +16,6 @@ serde = { version = "1", features = ["derive"] } serde_json = "1" magic-crypt = "3.1.13" rust-fuzzy-search = "0.1.1" -dotenv = "0.15.0" [features] # This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!! @@ -24,5 +23,6 @@ custom-protocol = ["tauri/custom-protocol"] [profile.release] lto = true # Enables link to optimizations -opt-level = "s" # Optimize for binary size +opt-level = "z" # Optimize for binary size strip = true # Remove debug symbols + diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 48f0126..39e3a8b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,11 +1,10 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] -use dotenv::dotenv; // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[path="tasks_functions.rs"] mod tasks; +mod config; fn main() { - dotenv().ok(); tauri::Builder::default() .invoke_handler(tauri::generate_handler![ tasks::check_or_create_tasks_file, diff --git a/src-tauri/src/tasks_functions.rs b/src-tauri/src/tasks_functions.rs index f335183..6584b7a 100644 --- a/src-tauri/src/tasks_functions.rs +++ b/src-tauri/src/tasks_functions.rs @@ -6,9 +6,11 @@ use std::fs::File; use serde_json::{Value, json}; use rust_fuzzy_search::fuzzy_search_best_n; -pub fn encrypt_n_save_file(path: PathBuf, content: String){ - let mc = new_magic_crypt!(std::env::var("ENC_KEY").unwrap(), 256); +use crate::config; +pub fn encrypt_n_save_file(path: PathBuf, content: String){ + let key = config::ENC_KEY; + let mc = new_magic_crypt!(key, 256); let mut encrypted: String = String::new(); for line in content.lines() { @@ -22,8 +24,8 @@ pub fn encrypt_n_save_file(path: PathBuf, content: String){ } pub fn decrypt_file(path: PathBuf) -> String { - let mc = new_magic_crypt!(std::env::var("ENC_KEY").unwrap(), 256); - + let key = config::ENC_KEY; + let mc = new_magic_crypt!(key, 256); let mut decrypted: String = String::new(); let lines = read_to_string(path); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 47ad829..4da76fc 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "to-do-app", - "version": "1.0.0" + "version": "1.5.0" }, "tauri": { "allowlist": { @@ -26,9 +26,6 @@ "unmaximize": true, "unminimize": true, "startDragging": true - }, - "fs": { - "scope": ["$RESOURCE/*"] } }, "windows": [ @@ -52,9 +49,6 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" - ], - "resources": [ - ".env" ] } }