mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
This commit is contained in:
committed by
GitHub
parent
fb2b9a52f5
commit
151e629ebf
5
.changes/streaming-small-file-fix.md
Normal file
5
.changes/streaming-small-file-fix.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": patch
|
||||
---
|
||||
|
||||
Fix streaming of small files using the `asset` protocol.
|
||||
@@ -350,7 +350,7 @@ impl<R: Runtime> WindowManager<R> {
|
||||
if range.length > file_size / 3 {
|
||||
// max size sent (400ko / request)
|
||||
// as it's local file system we can afford to read more often
|
||||
real_length = 1024 * 400;
|
||||
real_length = std::cmp::min(file_size - range.start, 1024 * 400);
|
||||
}
|
||||
|
||||
// last byte we are reading, the length of the range include the last byte
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
fn main() {
|
||||
use std::{
|
||||
cmp::min,
|
||||
io::{Read, Seek, SeekFrom},
|
||||
path::PathBuf,
|
||||
process::{Command, Stdio},
|
||||
@@ -74,7 +75,7 @@ fn main() {
|
||||
if range.length > file_size / 3 {
|
||||
// max size sent (400ko / request)
|
||||
// as it's local file system we can afford to read more often
|
||||
real_length = 1024 * 400;
|
||||
real_length = min(file_size - range.start, 1024 * 400);
|
||||
}
|
||||
|
||||
// last byte we are reading, the length of the range include the last byte
|
||||
|
||||
@@ -96,7 +96,7 @@ async function invoke<T>(cmd: string, args: InvokeArgs = {}): Promise<T> {
|
||||
* Convert a device file path to an URL that can be loaded by the webview.
|
||||
* Note that `asset:` must be allowed on the `csp` value configured on `tauri.conf.json`.
|
||||
*
|
||||
* @param filePath the file path. On Windows, the drive name must be omitted, i.e. using `/Users/user/file.png` instead of `C:/Users/user/file.png`.
|
||||
* @param filePath the file path.
|
||||
*
|
||||
* @return the URL that can be used as source on the webview
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user