Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
fixed runtime issues
Browse files Browse the repository at this point in the history
  • Loading branch information
crapStone committed Jul 18, 2021
1 parent 3a37a86 commit 8254b68
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src-tauri/cabr2_load_save/src/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::PathBuf;

use tauri::{plugin::Plugin, Invoke, Params, Window};
use tauri::{async_runtime, plugin::Plugin, Invoke, Params, Window};

use cabr2_types::ProviderMapping;
use tokio::fs;
Expand Down Expand Up @@ -78,7 +78,7 @@ pub struct LoadSave<M: Params> {

impl<M: Params> LoadSave<M> {
pub fn new(_provider_mapping: ProviderMapping) -> Self {
tokio::runtime::Handle::current().spawn(init_handlers(_provider_mapping));
async_runtime::spawn(init_handlers(_provider_mapping));
LoadSave {
invoke_handler: Box::new(tauri::generate_handler![
save_document,
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/cabr2_logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use log::LevelFilter;
use cabr2_config::{read_config, BackendConfig, TMP_DIR};
use cabr2_types::logging::LogLevel;

fn setup_logger() -> Result<(), fern::InitError> {
async fn setup_logger() -> Result<(), fern::InitError> {
let mut log_file = TMP_DIR.clone();
log_file.push(format!("cabr2_{}.log", chrono::Local::now().format("%F_%H.%M.%S")));

let config = tokio::runtime::Handle::current().block_on(read_config());
let config = read_config().await;
let config = config
.unwrap_or_else(|e| {
eprintln!("loading config failed: {}", e);
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/cabr2_logger/src/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde_json::{to_string_pretty, Value};
use tauri::{plugin::Plugin, Invoke, Params, Window};
use tauri::{async_runtime, plugin::Plugin, Invoke, Params, Window};

use cabr2_types::logging::LogLevel;

Expand Down Expand Up @@ -36,7 +36,7 @@ pub struct Logger<M: Params> {

impl<M: Params> Logger<M> {
pub fn new() -> Self {
setup_logger().unwrap();
async_runtime::block_on(setup_logger()).unwrap();

Logger {
invoke_handler: Box::new(tauri::generate_handler![log]),
Expand Down

0 comments on commit 8254b68

Please sign in to comment.