Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android & AppImage Build #292

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y build-essential curl wget file libssl-dev libayatana-appindicator3-dev \
libwebkit2gtk-4.1-dev librsvg2-dev
libwebkit2gtk-4.1-dev librsvg2-dev xdg-utils

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
Expand Down
14 changes: 12 additions & 2 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ members = [
]

[patch.crates-io]
cc = { git = "https://github.com/mariotaku/cc-rs.git", rev = "01a3414" }
r2d2 = { git = "https://github.com/mariotaku/r2d2.git", rev = "aaa2a2b" }
4 changes: 2 additions & 2 deletions src-tauri/src/device_manager/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::error::Error;

pub(crate) async fn read(conf_dir: &Path) -> Result<Vec<Device>, Error> {
let conf_dir = conf_dir.to_path_buf();
return tokio::task::spawn_blocking(move || -> Result<Vec<Device>, Error> {
return tauri::async_runtime::spawn_blocking(move || -> Result<Vec<Device>, Error> {
let path = devices_file_path(&conf_dir);
let file = match File::open(path.as_path()) {
Ok(file) => file,
Expand All @@ -35,7 +35,7 @@ pub(crate) async fn read(conf_dir: &Path) -> Result<Vec<Device>, Error> {

pub(crate) async fn write(devices: Vec<Device>, conf_dir: &Path) -> Result<(), Error> {
let conf_dir = conf_dir.to_path_buf();
return tokio::task::spawn_blocking(move || -> Result<(), Error> {
return tauri::async_runtime::spawn_blocking(move || -> Result<(), Error> {
let path = devices_file_path(&conf_dir);
let file = match File::create(path.as_path()) {
Ok(file) => file,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/device_manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl DeviceManager {
async fn ssh_probe(host: &str, port: u16, user: &str) -> Result<String, Error> {
let host = host.to_string();
let user = user.to_string();
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let ssh_sess = Session::new()?;
DeviceConnection::session_init(&ssh_sess)?;
ssh_sess.set_option(libssh_rs::SshOption::Hostname(host))?;
Expand Down
36 changes: 16 additions & 20 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ extern crate core;
use std::env;
use std::path::PathBuf;

#[cfg(feature = "desktop")]
use native_dialog::{MessageDialog, MessageType};
use ssh_key::PrivateKey;
use tauri::webview::PageLoadEvent;
use tauri::{AppHandle, Manager, RunEvent, Runtime};

#[cfg(target_os = "android")]
use android_logger::Config;

use crate::app_dirs::{GetAppSshKeyDir, GetConfDir, GetSshDir, SetConfDir, SetSshDir};
use crate::device_manager::DeviceManager;
use crate::error::Error;
Expand All @@ -33,15 +28,13 @@ mod shell_manager;
mod spawn_manager;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
#[tokio::main]
pub async fn run() {
pub fn run() {
#[cfg(target_os = "android")]
{
use android_logger::Config;
android_logger::init_once(Config::default().with_max_level(log::LevelFilter::Debug));
}

tauri::async_runtime::set(tokio::runtime::Handle::current());

let mut builder = tauri::Builder::default();
#[cfg(feature = "tauri-plugin-single-instance")]
{
Expand Down Expand Up @@ -92,17 +85,20 @@ pub async fn run() {
return Ok(());
});
#[cfg(feature = "desktop")]
if let Err(e) = result {
#[cfg(windows)]
if let tauri::Error::Runtime(ref e) = e {
if format!("{:?}", e).starts_with("CreateWebview(") {
MessageDialog::new()
.set_type(MessageType::Error)
.set_title("webOS Dev Manager")
.set_text(&format!("Unexpected error occurred: {:?}\nThis may be due to broken installation of WebView2 Runtime. You may need to reinstall WebView2 Runtime as administrator.", e))
.show_alert()
.expect("Unexpected error occurred while processing unexpected error :(");
return;
{
use native_dialog::{MessageDialog, MessageType};
if let Err(e) = result {
#[cfg(windows)]
if let tauri::Error::Runtime(ref e) = e {
if format!("{:?}", e).starts_with("CreateWebview(") {
MessageDialog::new()
.set_type(MessageType::Error)
.set_title("webOS Dev Manager")
.set_text(&format!("Unexpected error occurred: {:?}\nThis may be due to broken installation of WebView2 Runtime. You may need to reinstall WebView2 Runtime as administrator.", e))
.show_alert()
.expect("Unexpected error occurred while processing unexpected error :(");
return;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/plugins/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn exec<R: Runtime>(
encoding: Option<Encoding>,
) -> Result<ExecOutput, Error> {
let encoding = encoding.unwrap_or(Encoding::Binary);
return tokio::task::spawn_blocking(move || {
return tauri::async_runtime::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
return sessions.with_session(device, |session| {
let ch = session.new_channel()?;
Expand Down Expand Up @@ -70,7 +70,7 @@ async fn spawn<R: Runtime>(
let token = channel.token();
let proc = Arc::new(sessions.spawn(device, &command));
channel.listen(ProcEventHandler { proc: proc.clone() });
tokio::task::spawn_blocking(move || proc_worker(app, proc, channel, managed.unwrap_or(true)));
tauri::async_runtime::spawn_blocking(move || proc_worker(app, proc, channel, managed.unwrap_or(true)));
return Ok(token);
}

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/plugins/devmode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async fn valid_token<R: Runtime>(
app: AppHandle<R>,
device: Device,
) -> Result<Option<String>, Error> {
let data = tokio::task::spawn_blocking(move || {
let data = tauri::async_runtime::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
return sessions.with_session(device, |session| {
let sftp = session.sftp()?;
Expand Down
14 changes: 7 additions & 7 deletions src-tauri/src/plugins/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn ls<R: Runtime>(
return Err(Error::new("Absolute path required"));
}
log::info!("ls {}", path);
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
return sessions.with_session(device, |session| {
let sftp = session.sftp()?;
Expand All @@ -58,7 +58,7 @@ async fn read<R: Runtime>(
path: String,
encoding: Option<String>,
) -> Result<Vec<u8>, Error> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
return sessions.with_session(device, |session| {
let sftp = session.sftp()?;
Expand Down Expand Up @@ -88,7 +88,7 @@ async fn write<R: Runtime>(
path: String,
content: Vec<u8>,
) -> Result<(), Error> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
return Ok(sessions.with_session(device, |session| {
let sftp = session.sftp()?;
Expand All @@ -113,7 +113,7 @@ async fn get<R: Runtime>(
target: String,
on_progress: Channel<CopyProgress>,
) -> Result<(), Error> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
let on_progress = on_progress.clone();
return sessions.with_session(device, move |session| {
Expand All @@ -137,7 +137,7 @@ async fn put<R: Runtime>(
source: String,
on_progress: Channel<CopyProgress>,
) -> Result<(), Error> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
let on_progress = on_progress.clone();
return sessions.with_session(device, move |session| {
Expand Down Expand Up @@ -261,7 +261,7 @@ pub fn protocol<R: Runtime>(
};
let device_name = device_name.to_string();
let path = format!("/{path}");
tokio::task::spawn(async move {
tauri::async_runtime::spawn(async move {
let devices = app.state::<DeviceManager>();
let Some(device) = devices.find(&device_name).await.ok().flatten() else {
resp.respond(
Expand All @@ -273,7 +273,7 @@ pub fn protocol<R: Runtime>(
return;
};
let app = app.clone();
match tokio::task::spawn_blocking(move || {
match tauri::async_runtime::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
return sessions.with_session(device, |session| {
let sftp = session.sftp()?;
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/remote_files/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub(crate) async fn exec<R: Runtime>(
};
channel.listen(handler);
let token = channel.token();
tokio::spawn(async move {
tokio::task::spawn_blocking(move || serve_worker(app, device, channel, path))
tauri::async_runtime::spawn(async move {
tauri::async_runtime::spawn_blocking(move || serve_worker(app, device, channel, path))
.await
.unwrap()
.unwrap_or(());
});
return Ok(token);
Ok(token)
}

fn serve_worker<R: Runtime>(
Expand Down
Loading