WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 11 additions & 22 deletions apps/desktop/src-tauri/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,19 @@ pub async fn upload_video(

info!("Uploading video {video_id}...");

let (stream, total_size) = file_reader_stream(file_path).await?;
let stream = progress(
app.clone(),
video_id.clone(),
stream.map(move |v| v.map(move |v| (total_size, v))),
);
let upload_id = api::upload_multipart_initiate(&app, &video_id).await?;

let stream = if let Some(channel) = channel {
tauri_progress(channel, stream).boxed()
} else {
stream.boxed()
};

let video_fut = singlepart_uploader(
let video_fut = progress(
app.clone(),
PresignedS3PutRequest {
video_id: video_id.clone(),
subpath: "result.mp4".to_string(),
method: PresignedS3PutRequestMethod::Put,
meta: Some(meta),
},
total_size,
stream.and_then(|(_, c)| async move { Ok(c) }),
);
video_id.clone(),
multipart_uploader(
app.clone(),
video_id.clone(),
upload_id.clone(),
from_pending_file_to_chunks(file_path.clone(), None),
),
)
.try_collect::<Vec<_>>();
Comment on lines +94 to +106
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Critical: Missing multipart upload completion call.

The multipart upload flow is incomplete. After collecting the uploaded parts, you must call the completion API to finalize the S3 object. Without this, the uploaded parts remain uncommitted and the video won't be accessible.

Apply this diff to add the missing completion step:

 let upload_id = api::upload_multipart_initiate(&app, &video_id).await?;

-let video_fut = progress(
+let parts_fut = progress(
     app.clone(),
     video_id.clone(),
     multipart_uploader(
         app.clone(),
         video_id.clone(),
         upload_id.clone(),
         from_pending_file_to_chunks(file_path.clone(), None),
     ),
 )
 .try_collect::<Vec<_>>();

+let video_fut = async {
+    let parts = parts_fut.await?;
+    let metadata = build_video_meta(&file_path)
+        .map_err(|e| format!("Failed to get video metadata: {e}"))
+        .ok();
+    api::upload_multipart_complete(&app, &video_id, &upload_id, &parts, metadata).await
+};
+
 // TODO: We don't report progress on image upload

Note: This mirrors the pattern used in InstantMultipartUpload::run at line 405.

Run the following script to confirm that api::upload_multipart_complete exists and verify there are no other callers that might be completing the upload on behalf of upload_video:


🏁 Script executed:

#!/bin/bash
# Verify the completion API exists and check usage patterns

# Find the completion function definition
echo "=== Checking for upload_multipart_complete definition ==="
ast-grep --pattern $'pub async fn upload_multipart_complete($$$) {
  $$$
}'

# Search for all callers of upload_multipart_complete
echo -e "\n=== Finding all callers of upload_multipart_complete ==="
rg -n --type=rust 'upload_multipart_complete' -C 2

Length of output: 1847


Missing multipart upload completion in upload_video
After collecting parts with .try_collect::<Vec<_>>(), await the parts future, build metadata, and invoke
api::upload_multipart_complete(&app, &video_id, &upload_id, &parts, metadata).await?
(as in InstantMultipartUpload::run) to finalize the S3 object.

🤖 Prompt for AI Agents
In apps/desktop/src-tauri/src/upload.rs around lines 94 to 106, the multipart
upload is initiated and parts are collected but never finalized; await the parts
future (e.g., let parts = video_fut.await? or similar), construct the metadata
required for the upload completion, and then call and await
api::upload_multipart_complete(&app, &video_id, &upload_id, &parts,
metadata).await? to complete the S3 multipart upload (ensure types match and
propagate errors).


// TODO: We don't report progress on image upload
let bytes = compress_image(screenshot_path).await?;
Expand Down
Loading