diff --git a/app/database/helpers/bulk_ops.py b/app/database/helpers/bulk_ops.py index 4578511e5..feefbb5bd 100644 --- a/app/database/helpers/bulk_ops.py +++ b/app/database/helpers/bulk_ops.py @@ -10,7 +10,6 @@ from sqlalchemy.ext.asyncio import AsyncSession from ..models import Asset, AssetCacheState, AssetInfo, AssetInfoMeta, AssetInfoTag from ..timeutil import utcnow - MAX_BIND_PARAMS = 800 diff --git a/app/database/services/content.py b/app/database/services/content.py index 11eff76f9..05450f823 100644 --- a/app/database/services/content.py +++ b/app/database/services/content.py @@ -642,10 +642,9 @@ async def touch_asset_infos_by_fs_path( file_path: str, ts: Optional[datetime] = None, only_if_newer: bool = True, -) -> int: +) -> None: locator = os.path.abspath(file_path) ts = ts or utcnow() - stmt = sa.update(AssetInfo).where( sa.exists( sa.select(sa.literal(1)) @@ -656,7 +655,6 @@ async def touch_asset_infos_by_fs_path( ) ) ) - if only_if_newer: stmt = stmt.where( sa.or_( @@ -664,11 +662,7 @@ async def touch_asset_infos_by_fs_path( AssetInfo.last_access_time < ts, ) ) - - stmt = stmt.values(last_access_time=ts) - - res = await session.execute(stmt) - return int(res.rowcount or 0) + await session.execute(stmt.values(last_access_time=ts)) async def list_cache_states_with_asset_under_prefixes( diff --git a/app/database/services/info.py b/app/database/services/info.py index 758338368..8a28bcf4c 100644 --- a/app/database/services/info.py +++ b/app/database/services/info.py @@ -373,17 +373,14 @@ async def touch_asset_info_by_id( asset_info_id: str, ts: Optional[datetime] = None, only_if_newer: bool = True, -) -> bool: +) -> None: ts = ts or utcnow() stmt = sa.update(AssetInfo).where(AssetInfo.id == asset_info_id) if only_if_newer: stmt = stmt.where( sa.or_(AssetInfo.last_access_time.is_(None), AssetInfo.last_access_time < ts) ) - stmt = stmt.values(last_access_time=ts) - if session.bind.dialect.name == "postgresql": - return (await session.execute(stmt.returning(AssetInfo.id))).scalar_one_or_none() is not None - return int((await session.execute(stmt)).rowcount or 0) > 0 + await session.execute(stmt.values(last_access_time=ts)) async def delete_asset_info_by_id(session: AsyncSession, *, asset_info_id: str, owner_id: str) -> bool: @@ -391,8 +388,6 @@ async def delete_asset_info_by_id(session: AsyncSession, *, asset_info_id: str, AssetInfo.id == asset_info_id, visible_owner_clause(owner_id), ) - if session.bind.dialect.name == "postgresql": - return (await session.execute(stmt.returning(AssetInfo.id))).scalar_one_or_none() is not None return int((await session.execute(stmt)).rowcount or 0) > 0