fix: cover image not persisted to database on upload #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/cover-image-not-saved"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Cover image auto-set was never persisted to the database. The
CoverImageHelper.TrySetCoverImageIfNeededAsyncmethod setdoujin.CoverImageId = imageIdon the EF Core tracked entity but never calledSaveChangesAsync(). The change sat in the change tracker and was lost whentx.CommitAsync()was called without flushing it.This meant uploads appeared to succeed (pages + images were saved by
ImageService/PageServicewhich callSaveChangesAsync()internally), but the doujin'scover_image_idcolumn stayednull— no thumbnails in the library or detail views.Fix
Added
await db.SaveChangesAsync(ct);after settingCoverImageIdin the helper:The
SaveChangesAsynccall executes theUPDATE doujins SET cover_image_id = ...within the existing transaction, so it's atomic with the page/image inserts. The subsequenttx.CommitAsync()then commits everything together.1 file, 2 lines changed. All existing tests pass.
Summary
Summary
Coverage
DoujinManager.ApplicationCore - 85.2%
DoujinManager.Infrastructure - 93%
pshot
E20E2ABA2099901FFAB4904C0513DF077BA6D6CA374__CoverImageHelper
DoujinManager.RestAdapter - 84.9%
E5CB12CEAC5BBBEA65844E1C05F9ADA4DA38B848075C41304FC6A1ABF77__ValidationAttr
ibuteCache
DoujinManager.Server - 21.8%