mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2025-12-12 15:35:00 +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 ..models import Asset, AssetCacheState, AssetInfo, AssetInfoMeta, AssetInfoTag
|
||||||
from ..timeutil import utcnow
|
from ..timeutil import utcnow
|
||||||
|
|
||||||
|
|
||||||
MAX_BIND_PARAMS = 800
|
MAX_BIND_PARAMS = 800
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -642,10 +642,9 @@ async def touch_asset_infos_by_fs_path(
|
|||||||
file_path: str,
|
file_path: str,
|
||||||
ts: Optional[datetime] = None,
|
ts: Optional[datetime] = None,
|
||||||
only_if_newer: bool = True,
|
only_if_newer: bool = True,
|
||||||
) -> int:
|
) -> None:
|
||||||
locator = os.path.abspath(file_path)
|
locator = os.path.abspath(file_path)
|
||||||
ts = ts or utcnow()
|
ts = ts or utcnow()
|
||||||
|
|
||||||
stmt = sa.update(AssetInfo).where(
|
stmt = sa.update(AssetInfo).where(
|
||||||
sa.exists(
|
sa.exists(
|
||||||
sa.select(sa.literal(1))
|
sa.select(sa.literal(1))
|
||||||
@ -656,7 +655,6 @@ async def touch_asset_infos_by_fs_path(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if only_if_newer:
|
if only_if_newer:
|
||||||
stmt = stmt.where(
|
stmt = stmt.where(
|
||||||
sa.or_(
|
sa.or_(
|
||||||
@ -664,11 +662,7 @@ async def touch_asset_infos_by_fs_path(
|
|||||||
AssetInfo.last_access_time < ts,
|
AssetInfo.last_access_time < ts,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
await session.execute(stmt.values(last_access_time=ts))
|
||||||
stmt = stmt.values(last_access_time=ts)
|
|
||||||
|
|
||||||
res = await session.execute(stmt)
|
|
||||||
return int(res.rowcount or 0)
|
|
||||||
|
|
||||||
|
|
||||||
async def list_cache_states_with_asset_under_prefixes(
|
async def list_cache_states_with_asset_under_prefixes(
|
||||||
|
|||||||
@ -373,17 +373,14 @@ async def touch_asset_info_by_id(
|
|||||||
asset_info_id: str,
|
asset_info_id: str,
|
||||||
ts: Optional[datetime] = None,
|
ts: Optional[datetime] = None,
|
||||||
only_if_newer: bool = True,
|
only_if_newer: bool = True,
|
||||||
) -> bool:
|
) -> None:
|
||||||
ts = ts or utcnow()
|
ts = ts or utcnow()
|
||||||
stmt = sa.update(AssetInfo).where(AssetInfo.id == asset_info_id)
|
stmt = sa.update(AssetInfo).where(AssetInfo.id == asset_info_id)
|
||||||
if only_if_newer:
|
if only_if_newer:
|
||||||
stmt = stmt.where(
|
stmt = stmt.where(
|
||||||
sa.or_(AssetInfo.last_access_time.is_(None), AssetInfo.last_access_time < ts)
|
sa.or_(AssetInfo.last_access_time.is_(None), AssetInfo.last_access_time < ts)
|
||||||
)
|
)
|
||||||
stmt = stmt.values(last_access_time=ts)
|
await session.execute(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
|
|
||||||
|
|
||||||
|
|
||||||
async def delete_asset_info_by_id(session: AsyncSession, *, asset_info_id: str, owner_id: str) -> bool:
|
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,
|
AssetInfo.id == asset_info_id,
|
||||||
visible_owner_clause(owner_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
|
return int((await session.execute(stmt)).rowcount or 0) > 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user