mirror of
https://github.com/zhaofengli/attic.git
synced 2024-12-14 11:57:30 +00:00
server/upload_path: Expose the final file size in the response
This commit is contained in:
parent
332ac5051c
commit
064a747bb4
2 changed files with 10 additions and 0 deletions
|
@ -57,6 +57,10 @@ pub struct UploadPathNarInfo {
|
|||
pub struct UploadPathResult {
|
||||
#[serde_as(deserialize_as = "DefaultOnError")]
|
||||
pub kind: UploadPathResultKind,
|
||||
|
||||
/// The compressed size of the NAR, in bytes.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub file_size: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
|
@ -188,11 +188,16 @@ async fn upload_path_dedup(
|
|||
|
||||
txn.commit().await.map_err(ServerError::database_error)?;
|
||||
|
||||
let file_size = existing_nar.file_size
|
||||
.map(|dbs| dbs.try_into().map_err(ServerError::database_error))
|
||||
.transpose()?;
|
||||
|
||||
// Ensure it's not unlocked earlier
|
||||
drop(existing_nar);
|
||||
|
||||
Ok(Json(UploadPathResult {
|
||||
kind: UploadPathResultKind::Deduplicated,
|
||||
file_size,
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -339,6 +344,7 @@ async fn upload_path_new(
|
|||
|
||||
Ok(Json(UploadPathResult {
|
||||
kind: UploadPathResultKind::Uploaded,
|
||||
file_size: Some(*file_size),
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue