#Avoid Application Freeze When WriteFile

8 messages · Page 1 of 1 (latest)

smoky timber
#

How to create dummy files A, B, C, D with different sizes simultaneously, without experiencing application freezing?

I have tried creating a single file with a size of 20MB filled with only byte 00, but during the creation process, the application freezing.

windows 11 - tauri v2

the code I used to try to create the file

import { writeFile, BaseDirectory } from "@tauri-apps/plugin-fs";
await writeFile(`path/dummyfile.dll`, new Uint8Array(14768592));
timid moon
smoky timber
# timid moon https://github.com/tauri-apps/tauri/issues/9322#issuecomment-2029855260 try usin...

i got the error/log

enter rust time: 21:58:37.964800200
thread 'tokio-runtime-worker' panicked at src\main.rs:71:9:
not yet implemented

my cargo.toml

[package]
name = "tauri-app"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "2.0.0-beta", features = [] }

[dependencies]
tauri = { version = "2.0.0-beta", features = [] }
tauri-plugin-shell = "2.0.0-beta"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-dialog = "2.0.0-beta.4"
tauri-plugin-fs = "2.0.0-beta.4"
systemstat = "0.2.3"
chrono = "0.4"

Is this not implemented yet, or where do I need to activate it?

call code

  invoke("new_append_chunk_to_file", new Uint8Array([]), {
    headers: {
      path: `/path/to/test.dll`,
      end: "false",
    },
  });

command code

#[tauri::command]
async fn new_append_chunk_to_file(
    request: tauri::ipc::Request<'_>,
) -> Result<(), String>  {
    let current_time = Local::now().time();
    println!("enter rust time: {}", current_time);
    if let tauri::ipc::InvokeBody::Raw(data) = request.body() {
        let path = PathBuf::from(request.headers().get("path").unwrap().to_str().unwrap());
        // let end = request.headers().get("end").unwrap() == "true";
        let mut file = OpenOptions::new()
            .create(true)
            .append(true)
            .open(&path)
            .map_err(|e| e.to_string())
            .unwrap();
        file.write_all(data).map_err(|e| e.to_string()).unwrap();
        let current_time = Local::now().time();
        println!("return time: {}", current_time);
        Ok(())
    } else {
        todo!()
    }
}
timid moon
smoky timber
timid moon
#

its empty, maybe thats why

smoky timber
# timid moon its empty, maybe thats why
  const dataString = "Hello, world!";
  const buffer = new TextEncoder().encode(dataString);
  const dataChunk = new Uint8Array(buffer);

  invoke("new_append_chunk_to_file", dataChunk, {

its still trigger todo!(), it should no longer be empty

timid moon
#

sorry, im literally 0 in Rust