Skip to content

Commit

Permalink
publish: v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ugo-studio committed Jun 21, 2024
1 parent cce0bed commit a995727
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion bin/server/lib/file-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ export class FileServer {
if (req) {
sending = true;
// send stream to the receiver
const { readable, writable } = new TransformStream();
await new Promise<void>(async (r) => {
try {
const { readable, writable } = new TransformStream();
const file: File | null = (await req.formData()).get(
"file"
) as any;
file?.stream()?.pipeTo(writable);
resolve(readable);
console.log(`piping file to response: ${name}`);
// wait for receiver to consume the stream
const timeout = setTimeout(() => {
clearInterval(timer);
Expand All @@ -102,6 +103,7 @@ export class FileServer {
}, 2000);
} catch (err) {
r();
writable.close();
console.error(`error sending stream: ${err}`);
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filestream",
"version": "1.0.3",
"version": "1.0.4",
"description": "",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "filestream",
"version": "1.0.3"
"version": "1.0.4"
},
"tauri": {
"allowlist": {
Expand Down
15 changes: 8 additions & 7 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import QrcodeView from "../comp/qrcode-view.svelte";
import Username from "../comp/username.svelte";
import { Child, Command } from "@tauri-apps/api/shell";
import { resourceDir } from "@tauri-apps/api/path";
import { resolveResource } from "@tauri-apps/api/path";
let server = new FileServer();
let command: Command | undefined;
let process: Child | undefined;
let webFiles: string | undefined;
let showQr = false;
onMount(async () => {
Expand All @@ -27,7 +28,7 @@
let shareAddr = `${serverAddr}/?s=${encodeURIComponent(serverAddr)}`;
server.serverAddr = serverAddr;
server.shareAddr = shareAddr;
console.log(info, serverAddr, shareAddr);
console.log(info, { serverAddr, shareAddr, webFiles });
}
}
server.connect();
Expand All @@ -42,17 +43,17 @@
const startProcess = () =>
new Promise<any>(async (resolve) => {
command = Command.sidecar(
"bin/server",
encodeURIComponent(await resourceDir())
);
webFiles = await resolveResource("../build");
command = Command.sidecar("bin/server", encodeURIComponent(webFiles));
command.on("error", (_) => resolve(process?.kill()));
command.on("close", (_) => resolve(process?.kill()));
command.stdout.on("data", (d) => {
try {
let json = JSON.parse(String(d));
resolve(json);
} catch (_) {}
} catch (_) {
console.log(d);
}
});
process = await command.spawn();
});
Expand Down

0 comments on commit a995727

Please sign in to comment.