feat: assemble completed uploads
Implement POST /api/uploads/{id}/complete. The storage layer now reloads upload
metadata, verifies that every expected chunk exists with the exact expected
length, concatenates chunks in order into a temporary final file, flushes it,
and renames it into data/complete only after assembly succeeds.
The endpoint preserves staging data after completion, rejects incomplete uploads
with a conflict response, and refuses to overwrite an existing completed file.
This keeps failed or duplicate completion attempts explicit rather than silently
clobbering local files.
Extend the model, router, documentation, and test checklist for completion
responses and add integration coverage for successful assembly, incomplete
uploads, staging preservation, and duplicate completion conflicts.
Test Plan:
- just check
Refs: PLAN.md milestone 8
This commit is contained in:
@@ -27,6 +27,13 @@ pub struct UploadProgressResponse {
|
||||
pub completed_chunks: Vec<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct CompleteUploadResponse {
|
||||
pub upload_id: String,
|
||||
pub name: String,
|
||||
pub file_path: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct UploadMeta {
|
||||
pub id: String,
|
||||
@@ -61,4 +68,13 @@ impl UploadMeta {
|
||||
completed_chunks,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn complete_response(&self, file_path: String) -> CompleteUploadResponse {
|
||||
CompleteUploadResponse {
|
||||
upload_id: self.id.clone(),
|
||||
name: self.safe_name.clone(),
|
||||
file_path,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user