mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2025-12-11 06:54:26 +08:00
final adjustments
This commit is contained in:
parent
1a37d1476d
commit
283cd27bdc
@ -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
|
||||
|
||||
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user