Skip to content

Commit 283cd27

Browse files
committed
final adjustments
1 parent 1a37d14 commit 283cd27

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

app/database/helpers/bulk_ops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from ..models import Asset, AssetCacheState, AssetInfo, AssetInfoMeta, AssetInfoTag
1111
from ..timeutil import utcnow
1212

13-
1413
MAX_BIND_PARAMS = 800
1514

1615

app/database/services/content.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,9 @@ async def touch_asset_infos_by_fs_path(
642642
file_path: str,
643643
ts: Optional[datetime] = None,
644644
only_if_newer: bool = True,
645-
) -> int:
645+
) -> None:
646646
locator = os.path.abspath(file_path)
647647
ts = ts or utcnow()
648-
649648
stmt = sa.update(AssetInfo).where(
650649
sa.exists(
651650
sa.select(sa.literal(1))
@@ -656,19 +655,14 @@ async def touch_asset_infos_by_fs_path(
656655
)
657656
)
658657
)
659-
660658
if only_if_newer:
661659
stmt = stmt.where(
662660
sa.or_(
663661
AssetInfo.last_access_time.is_(None),
664662
AssetInfo.last_access_time < ts,
665663
)
666664
)
667-
668-
stmt = stmt.values(last_access_time=ts)
669-
670-
res = await session.execute(stmt)
671-
return int(res.rowcount or 0)
665+
await session.execute(stmt.values(last_access_time=ts))
672666

673667

674668
async def list_cache_states_with_asset_under_prefixes(

app/database/services/info.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,26 +373,21 @@ async def touch_asset_info_by_id(
373373
asset_info_id: str,
374374
ts: Optional[datetime] = None,
375375
only_if_newer: bool = True,
376-
) -> bool:
376+
) -> None:
377377
ts = ts or utcnow()
378378
stmt = sa.update(AssetInfo).where(AssetInfo.id == asset_info_id)
379379
if only_if_newer:
380380
stmt = stmt.where(
381381
sa.or_(AssetInfo.last_access_time.is_(None), AssetInfo.last_access_time < ts)
382382
)
383-
stmt = stmt.values(last_access_time=ts)
384-
if session.bind.dialect.name == "postgresql":
385-
return (await session.execute(stmt.returning(AssetInfo.id))).scalar_one_or_none() is not None
386-
return int((await session.execute(stmt)).rowcount or 0) > 0
383+
await session.execute(stmt.values(last_access_time=ts))
387384

388385

389386
async def delete_asset_info_by_id(session: AsyncSession, *, asset_info_id: str, owner_id: str) -> bool:
390387
stmt = sa.delete(AssetInfo).where(
391388
AssetInfo.id == asset_info_id,
392389
visible_owner_clause(owner_id),
393390
)
394-
if session.bind.dialect.name == "postgresql":
395-
return (await session.execute(stmt.returning(AssetInfo.id))).scalar_one_or_none() is not None
396391
return int((await session.execute(stmt)).rowcount or 0) > 0
397392

398393

0 commit comments

Comments
 (0)