Summary
SFTP file operations (download_file_from_sftp, upload_file_to_sftp, copy) read entire files into a Vec<u8>, which will OOM on large files.
Current State
src-tauri/src/locations/sftp/mod.rs:385 — sftp.read(remote_path) loads full file
src-tauri/src/locations/sftp/mod.rs:408 — tokio::fs::read(local_path) loads full file
src-tauri/src/locations/sftp/mod.rs:268 — copy() reads full file into memory
- Same pattern exists in SMB provider (via sidecar)
Proposed Changes
Use russh-sftp's open() + chunked read()/write() instead of the convenience read()/write() methods:
let file = sftp.open(path).await?;
let mut buf = vec![0u8; 64 * 1024]; // 64KB chunks
loop {
let n = file.read(&mut buf).await?;
if n == 0 { break; }
dest.write_all(&buf[..n]).await?;
}
Acceptance Criteria
Summary
SFTP file operations (
download_file_from_sftp,upload_file_to_sftp,copy) read entire files into aVec<u8>, which will OOM on large files.Current State
src-tauri/src/locations/sftp/mod.rs:385—sftp.read(remote_path)loads full filesrc-tauri/src/locations/sftp/mod.rs:408—tokio::fs::read(local_path)loads full filesrc-tauri/src/locations/sftp/mod.rs:268—copy()reads full file into memoryProposed Changes
Use
russh-sftp'sopen()+ chunkedread()/write()instead of the convenienceread()/write()methods:Acceptance Criteria