fix: show actual file size for picked files
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 48s
CI / Lint & Test (pull_request) Failing after 5m42s
CI / Build Linux (pull_request) Has been skipped
CI / Build Windows (cross-compile) (pull_request) Has been skipped

This commit is contained in:
2026-01-24 16:14:33 -08:00
committed by Naomi Carrigan
parent 07f9cf8c30
commit 1e5c1c815e
3 changed files with 17 additions and 1 deletions
+7
View File
@@ -373,3 +373,10 @@ pub async fn cleanup_orphaned_temp_files(
let mut manager = temp_manager.lock();
manager.cleanup_orphaned_files()
}
#[tauri::command]
pub async fn get_file_size(file_path: String) -> Result<u64, String> {
let metadata = std::fs::metadata(&file_path)
.map_err(|e| format!("Failed to get file metadata: {}", e))?;
Ok(metadata.len())
}
+1
View File
@@ -77,6 +77,7 @@ pub fn run() {
cleanup_temp_files,
cleanup_all_temp_files,
cleanup_orphaned_temp_files,
get_file_size,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
+9 -1
View File
@@ -474,11 +474,19 @@ User: ${formattedMessage}`;
const extension = filename.split(".").pop()?.toLowerCase() || "";
const fileType = getFileTypeFromExtension(extension);
// Get file size from Tauri
let fileSize = 0;
try {
fileSize = await invoke<number>("get_file_size", { filePath });
} catch (e) {
console.warn("Could not get file size:", e);
}
const attachment: Attachment = {
id: `attachment-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
filename,
path: filePath,
size: 0,
size: fileSize,
type: fileType,
};