Skip to content

Commit a8b6202

Browse files
committed
Added More Workspace Stability
1 parent 2ee83f8 commit a8b6202

5 files changed

Lines changed: 37 additions & 29 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ rand = "0.8.5"
1919
tokio = { version = "1.37.0", features = ["full"] }
2020
tokio-util = "0.7.11"
2121
bytes = "1.6.0"
22+
23+
[profile.dev]
24+
opt-level = 1

core/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ thiserror = { workspace = true }
1616
futures-buffered = { workspace = true }
1717
futures-lite = { workspace = true }
1818
serde = { workspace = true }
19+
rand.workspace = true
20+
tokio.workspace = true
21+
1922
postcard = "1.0.8"
2023
uniffi = { version = "0.28.0" }
21-
rand.workspace = true
2224
data-encoding = "2.6.0"
2325
async-channel = "2.3.1"
24-
tokio.workspace = true
2526
tracing-subscriber = "0.3.19"
2627

2728
[build-dependencies]

src-tauri/Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@ crate-type = ["staticlib", "cdylib", "rlib"]
1717
tauri-build = { version = "2", features = [] }
1818

1919
[dependencies]
20-
drop_core = { path = "../core" }
2120
tauri = { version = "2", features = [] }
2221
dirs = "5.0.1"
2322
open = "5.1.3"
23+
tauri-plugin-dialog = "2"
24+
tauri-plugin-opener = "2"
25+
tauri-plugin-clipboard-manager = "2.0.0-alpha.2"
26+
27+
drop_core = { path = "../core" }
2428

2529
iroh-blobs = { workspace = true }
2630
iroh-base = { workspace = true }
2731
anyhow = { workspace = true }
2832

2933
tokio = { workspace = true, features = ["full"] }
30-
tauri-plugin-dialog = "2"
31-
tauri-plugin-opener = "2"
32-
tauri-plugin-clipboard-manager = "2.0.0-alpha.2"
3334

34-
serde = { version = "1.0", features = ["derive"] }
35-
serde_json = "1.0"
35+
serde_json = { workspace = true }
36+
serde = { workspace = true }
3637

3738
[features]
3839
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.

src-tauri/src/lib.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,32 +125,30 @@ async fn receive_files(
125125
) -> Result<String, InvokeError> {
126126
let async_proc_input_tx = state.inner.lock().await.clone();
127127

128-
let mut handles = Vec::new();
128+
let (tx, mut rx) = tokio::sync::mpsc::channel::<Vec<FileTransfer>>(2);
129129

130-
let (tx, rx) = std::sync::mpsc::channel::<Vec<FileTransfer>>();
131-
132-
handles.push(tokio::spawn(async move {
130+
let handle = tokio::spawn(async move {
133131
loop {
134-
let files = rx.recv();
135-
if let Ok(files) = files {
132+
let files = rx.recv().await;
133+
if let Some(files) = files {
136134
let _ = async_proc_input_tx.send(Event::Files(files)).await;
137135
} else {
138136
break;
139137
}
140138
}
141-
}));
139+
});
140+
141+
let outpath = dirs::download_dir().expect("No Downloads Dir");
142142

143-
// let files = IrohInstance::receive_files(ticket, tx)
144-
// .await
145-
// .map_err(|e| InvokeError::from_anyhow(anyhow!(e)))?;
143+
let files = IrohInstance::receive_files(ticket, tx)
144+
.await
145+
.map_err(|e| InvokeError::from_anyhow(anyhow!(e)))?;
146146

147-
// println!("files: {:?}", files);
147+
println!("files: {:?}", files);
148148

149-
for handle in handles {
150-
handle.await.unwrap();
151-
}
149+
handle.await.unwrap();
152150

153-
Ok("[TEST]".into())
151+
Ok(outpath.to_str().unwrap().to_owned())
154152
}
155153

156154
#[tauri::command]

src/routes/transfers/transferring/+page.svelte

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@
1919
let transferFiles: FileTransferDTO[] = [];
2020
2121
onMount(async () => {
22-
let start = Date.now();
23-
output = await invoke('receive_files', {
24-
ticket: data.ticket
25-
});
26-
time_complete = Date.now() - start;
27-
done = true;
22+
try {
23+
let start = Date.now();
24+
output = await invoke('receive_files', {
25+
ticket: data.ticket
26+
});
27+
time_complete = Date.now() - start;
28+
done = true;
29+
} catch (error) {
30+
console.error("ERROR:", error)
31+
}
32+
2833
});
2934
3035
listen('download_progress', (event) => {

0 commit comments

Comments
 (0)