Skip to content

Commit

Permalink
Add proper StartFileUploadOutput struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Sep 9, 2024
1 parent 68aeeb3 commit 438daa7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 9 additions & 4 deletions deepwell/src/services/file/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ impl FileService {
};

let file = model.insert(txn).await?;

FileRevisionService::create_pending(
let file_revision = FileRevisionService::create_pending(
ctx,
CreatePendingFileRevision {
site_id,
Expand All @@ -91,7 +90,13 @@ impl FileService {
comments: revision_comments,
},
)
.await
.await?;

Ok(StartFileUploadOutput {
pending_blob_id: pending.pending_blob_id,
presign_url: pending.presign_url,
file_revision_id: file_revision.file_revision_id,
})
}

pub async fn finish_new_upload(
Expand All @@ -108,7 +113,7 @@ impl FileService {
site_id, page_id, file_id, pending_blob_id,
);

// Ensure file exists
// Ensure a pending file exists
let txn = ctx.transaction();
let row = File::find()
.filter(
Expand Down
8 changes: 6 additions & 2 deletions deepwell/src/services/file/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ pub struct StartFileUpload {
pub bypass_filter: bool,
}

// TODO
pub type StartFileUploadOutput = CreateFirstFileRevisionOutput;
#[derive(Serialize, Debug, Clone)]
pub struct StartFileUploadOutput {
pub pending_blob_id: i64,
pub presign_url: String,
pub file_revision_id: i64,
}

#[derive(Deserialize, Debug, Clone)]
pub struct FinishUploadFile {
Expand Down

0 comments on commit 438daa7

Please sign in to comment.