Skip to content

Commit

Permalink
fixed build
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Aug 11, 2024
1 parent 2309f7e commit d6c3719
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Ningyuan Li"]
license = "Apache-2.0"
repository = "https://github.com/webosbrew/dev-manager-desktop"
edition = "2021"
rust-version = "1.76.0"
rust-version = "1.80.1"
links = "devman"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/capabilities/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"main"
],
"permissions": [
"event:default",
"webview:default",
"path:default",
"path:allow-resolve-directory",
"core:event:default",
"core:webview:default",
"core:path:default",
"core:path:allow-resolve-directory",
"fs:default",
"shell:allow-open",
"dialog:allow-open",
Expand Down
8 changes: 5 additions & 3 deletions src-tauri/src/event_channel/channel.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::event_channel::{EventChannel, EventHandler};
use serde::Serialize;
use std::sync::{Arc, Mutex};
use tauri::{AppHandle, Manager, Runtime};

use serde::Serialize;
use tauri::{AppHandle, Emitter, Listener, Runtime};
use uuid::Uuid;

use crate::event_channel::{EventChannel, EventHandler};

impl<R, H> EventChannel<R, H>
where
R: Runtime,
Expand Down
29 changes: 18 additions & 11 deletions src-tauri/src/plugins/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ use std::path::Path;
use flate2::read::GzDecoder;
use libssh_rs::OpenFlags;
use serde::Serialize;
use tauri::ipc::Channel;
use tauri::plugin::{Builder, TauriPlugin};
use tauri::{AppHandle, Manager, Runtime};
use tauri::ipc::{Channel, IpcResponse};
use tauri::plugin::{Builder, TauriPlugin};
use uuid::Uuid;

use crate::device_manager::Device;
use crate::error::Error;
use crate::remote_files::serve;
use crate::remote_files::{FileItem, PermInfo};
use crate::remote_files::serve;
use crate::session_manager::SessionManager;

#[derive(Clone, Serialize)]
#[derive(Copy, Clone, Serialize)]
struct CopyProgress {
copied: usize,
total: usize,
Expand Down Expand Up @@ -91,8 +91,11 @@ async fn write<R: Runtime>(
let sessions = app.state::<SessionManager>();
return Ok(sessions.with_session(device, |session| {
let sftp = session.sftp()?;
let mut file =
sftp.open(&path, OpenFlags::WRITE_ONLY | OpenFlags::CREATE | OpenFlags::TRUNCATE, 0o644)?;
let mut file = sftp.open(
&path,
OpenFlags::WRITE_ONLY | OpenFlags::CREATE | OpenFlags::TRUNCATE,
0o644,
)?;
file.write_all(&content)?;
return Ok(());
})?);
Expand All @@ -107,7 +110,7 @@ async fn get<R: Runtime>(
device: Device,
path: String,
target: String,
on_progress: Channel,
on_progress: Channel<CopyProgress>,
) -> Result<(), Error> {
return tokio::task::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
Expand All @@ -131,15 +134,19 @@ async fn put<R: Runtime>(
device: Device,
path: String,
source: String,
on_progress: Channel,
on_progress: Channel<CopyProgress>,
) -> Result<(), Error> {
return tokio::task::spawn_blocking(move || {
let sessions = app.state::<SessionManager>();
let on_progress = on_progress.clone();
return sessions.with_session(device, move |session| {
let sftp = session.sftp()?;
let mut sfile = sftp
.open(&path, OpenFlags::WRITE_ONLY | OpenFlags::CREATE | OpenFlags::TRUNCATE, 0o644)
.open(
&path,
OpenFlags::WRITE_ONLY | OpenFlags::CREATE | OpenFlags::TRUNCATE,
0o644,
)
.map_err(|e| {
let e: Error = e.into();
return match e {
Expand Down Expand Up @@ -175,7 +182,7 @@ fn copy<R: ?Sized, W: ?Sized>(
reader: &mut R,
writer: &mut W,
total: usize,
progress: &Channel,
progress: &Channel<CopyProgress>,
) -> std::io::Result<usize>
where
R: Read,
Expand Down Expand Up @@ -208,7 +215,7 @@ async fn get_temp<R: Runtime>(
app: AppHandle<R>,
device: Device,
path: String,
on_progress: Channel,
on_progress: Channel<CopyProgress>,
) -> Result<String, Error> {
let source = Path::new(&path);
let extension = source
Expand Down
6 changes: 2 additions & 4 deletions src-tauri/src/plugins/shell.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use tauri::plugin::{Builder, TauriPlugin};
use tauri::{AppHandle, Manager, Runtime, State};
use tauri::{AppHandle, Emitter, Manager, Runtime, State};

use crate::device_manager::Device;
use crate::error::Error;
Expand Down Expand Up @@ -102,8 +102,6 @@ impl<R: Runtime> ShellCallback for PluginShellCb<R> {
.emit("shell-removed", self.token.clone())
.unwrap_or(());
}
self.app
.emit("shells-updated", shells.list())
.unwrap_or(());
self.app.emit("shells-updated", shells.list()).unwrap_or(());
}
}

0 comments on commit d6c3719

Please sign in to comment.