Skip to content

Commit

Permalink
fix: the migrate script will block application startup
Browse files Browse the repository at this point in the history
Signed-off-by: 1111mp <The1111mp@outlook.com>
  • Loading branch information
1111mp committed Nov 6, 2024
1 parent e0a79be commit 8c4c923
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src-tauri/src/utils/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
use anyhow::Result;
use std::time::Duration;
use tauri::{Emitter, Manager};
use tokio::fs;
use tokio::time::sleep;

use super::{dirs, help};
use crate::core::handle;

use anyhow::Result;
use tauri::Emitter;
use tokio::fs;
use tokio::time::{sleep, Duration};

const CURRENT_MIGRATION_VERSION: i16 = 17;
const NODE_DEFAULT_EXECUTE: [&str; 4] = ["node", "npm", "npx", "corepack"];

pub async fn init() -> Result<()> {
if let Err(err) = update_schema().await {
log::error!(target: "migrate", "{err}");
pub fn init() -> Result<()> {
tauri::async_runtime::spawn(async {
if let Err(err) = update_schema().await {
log::error!(target: "migrate", "{err}");
}
// Delay 1s before sending events to the window
sleep(Duration::from_secs(1)).await;

if let Some(window) = handle::Handle::global().get_window() {
let _ = window.emit("app-migration-error", ());
}
}
});

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/utils/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub async fn resolve_setup(app: &mut App) {

handle::Handle::global().init(app.app_handle());

log_err!(migrate::init().await);
log_err!(migrate::init());
log_err!(tray::Tray::create_systray());

let silent_start = { Config::settings().data().enable_silent_start };
Expand Down

0 comments on commit 8c4c923

Please sign in to comment.