1616
1717from ai .backend .common .bgtask .bgtask import BackgroundTaskManager
1818from ai .backend .common .clients .valkey_client .valkey_stat .client import ValkeyStatClient
19+ from ai .backend .common .contexts .user import current_user
1920from ai .backend .common .defs import VFOLDER_GROUP_PERMISSION_MODE
2021from ai .backend .common .etcd import AsyncEtcd
22+ from ai .backend .common .exception import UnreachableError
2123from ai .backend .common .types import (
2224 QuotaScopeID ,
2325 QuotaScopeType ,
162164 PurgeVFolderV2Action ,
163165 PurgeVFolderV2ActionResult ,
164166)
165- from ai .backend .manager .services .vfolder .actions .vfolder_v2_rbac import (
166- DeleteVFolderV2RBACAction ,
167- DeleteVFolderV2RBACActionResult ,
168- )
169167from ai .backend .manager .services .vfolder .types import (
170168 VFolderBaseInfo ,
171169 VFolderOwnershipInfo ,
@@ -1630,19 +1628,17 @@ async def get_v2(self, action: GetVFolderV2Action) -> GetVFolderV2ActionResult:
16301628 return GetVFolderV2ActionResult (vfolder = vfolder_data )
16311629
16321630 async def delete_v2 (self , action : DeleteVFolderV2Action ) -> DeleteVFolderV2ActionResult :
1633- """Delete (trash) a vfolder (v2). Resolves policy internally from user_id."""
1634- user = await self ._user_repository .get_user_by_uuid (action .user_id )
1635- if not user .domain_name :
1636- raise VFolderInvalidParameter ("User has no domain assigned" )
1637- vfolder_data = await self ._vfolder_repository .get_by_id_validated (
1638- action .vfolder_id , user .id , user .domain_name
1639- )
1631+ """Soft-delete a vfolder by ID. RBAC enforced at processor level."""
1632+ me = current_user ()
1633+ if me is None :
1634+ raise UnreachableError ("User context is not available" )
1635+ vfolder_data = await self ._vfolder_repository .get_by_id (action .vfolder_id )
16401636
1641- # Host permission check — resolved from user_id
1637+ # Host permission check — resolved from current user context
16421638 await self ._vfolder_repository .ensure_host_permission_allowed_by_user (
16431639 vfolder_data .host ,
16441640 permission = VFolderHostPermission .DELETE ,
1645- user_uuid = action .user_id ,
1641+ user_uuid = me .user_id ,
16461642 )
16471643
16481644 await self ._vfolder_repository .move_vfolders_to_trash ([vfolder_data .id ])
@@ -1668,13 +1664,6 @@ async def purge_v2(self, action: PurgeVFolderV2Action) -> PurgeVFolderV2ActionRe
16681664 await self ._remove_vfolder_from_storage (vfolder_data )
16691665 return PurgeVFolderV2ActionResult (vfolder_id = action .vfolder_id )
16701666
1671- async def delete_v2_rbac (
1672- self , action : DeleteVFolderV2RBACAction
1673- ) -> DeleteVFolderV2RBACActionResult :
1674- """Soft-delete a vfolder by ID. RBAC enforced at processor level."""
1675- await self ._vfolder_repository .trash_vfolder (action .updater )
1676- return DeleteVFolderV2RBACActionResult (vfolder_id = action .vfolder_id )
1677-
16781667 async def clone_v2 (self , action : CloneVFolderV2Action ) -> CloneVFolderV2ActionResult :
16791668 """Clone a vfolder (v2). Resolves policy internally from user_id."""
16801669 allowed_vfolder_types = (
0 commit comments