commit early

This commit is contained in:
GitHub
2025-12-29 15:15:34 +08:00
parent 528aeb51e3
commit 2a497ea1df

View File

@@ -233,7 +233,6 @@ pub(crate) async fn upload_post(
let claim = Claim::get(&DB, &cookie, &site_config).ok_or(AppError::NonLogin)?;
let mut imgs = Vec::with_capacity(10);
let mut batch = DB.inner().batch();
let user_uploads = DB
.inner()
.open_partition("user_uploads", Default::default())?;
@@ -306,13 +305,11 @@ pub(crate) async fn upload_post(
fs::write(location, &img_data).await.unwrap();
let img_id = incr_id(&DB, "imgs_count")?;
let k = [u32_to_ivec(claim.uid), u32_to_ivec(img_id)].concat();
batch.insert(&user_uploads, k, fname.as_bytes());
user_uploads.insert(k, fname.as_bytes())?;
imgs.push(fname);
}
batch.commit()?;
let has_unread = User::has_unread(&DB, claim.uid)?;
let uid = claim.uid;
let page_data = PageData::new("upload images", &site_config, Some(claim), has_unread);