@@ -179,15 +179,16 @@ async def _write_direct_with_refresh(
179179 ) -> Dict [str , Any ]:
180180 lock_manager = get_lock_manager ()
181181 handle = lock_manager .create_handle ()
182- lock_path = self ._viking_fs ._uri_to_path (root_uri , ctx = ctx )
183- acquired = await lock_manager .acquire_tree (handle , lock_path )
182+ lock_path = self ._viking_fs ._uri_to_path (uri , ctx = ctx )
183+ acquired = await lock_manager .acquire_exact_path (handle , lock_path )
184184 if not acquired :
185185 await lock_manager .release (handle )
186186 raise InvalidArgumentError (f"resource is busy and cannot be written now: { uri } " )
187187
188188 previous_content : Optional [str ] = None
189189 content_written = False
190- lock_transferred = False
190+ semantic_enqueued = False
191+ lock_released = False
191192 try :
192193 if mode != "create" :
193194 previous_content = await self ._viking_fs .read_file (uri , ctx = ctx )
@@ -200,10 +201,12 @@ async def _write_direct_with_refresh(
200201 changed_uri = uri ,
201202 context_type = context_type ,
202203 ctx = ctx ,
203- lifecycle_lock_handle_id = handle . id ,
204+ lifecycle_lock_handle_id = "" ,
204205 change_type = "added" if mode == "create" else "modified" ,
205206 )
206- lock_transferred = True
207+ semantic_enqueued = True
208+ await lock_manager .release (handle )
209+ lock_released = True
207210 queue_status = (
208211 await self ._wait_for_request (telemetry_id = telemetry_id , timeout = timeout )
209212 if wait
@@ -219,15 +222,15 @@ async def _write_direct_with_refresh(
219222 queue_status = queue_status ,
220223 )
221224 except Exception :
222- if not lock_transferred and content_written :
225+ if not semantic_enqueued and content_written :
223226 await self ._rollback_direct_write (
224227 uri = uri ,
225228 previous_content = previous_content ,
226229 mode = mode ,
227230 ctx = ctx ,
228231 lock_handle = handle ,
229232 )
230- if not lock_transferred :
233+ if not lock_released :
231234 await lock_manager .release (handle )
232235 raise
233236 finally :
0 commit comments