rework + add test for concurrent AssetInfo delete

This commit is contained in:
bigcat88
2025-09-14 15:00:32 +03:00
parent cdd8d16075
commit 47f7c7ee8c
2 changed files with 47 additions and 5 deletions

View File

@@ -379,11 +379,12 @@ async def touch_asset_info_by_id(
async def delete_asset_info_by_id(session: AsyncSession, *, asset_info_id: str, owner_id: str) -> bool:
res = await session.execute(delete(AssetInfo).where(
AssetInfo.id == asset_info_id,
visible_owner_clause(owner_id),
))
return bool(res.rowcount)
return (
await session.execute(delete(AssetInfo).where(
AssetInfo.id == asset_info_id,
visible_owner_clause(owner_id),
).returning(AssetInfo.id))
).scalar_one_or_none() is not None
async def add_tags_to_asset_info(