@@ -287,24 +287,13 @@ async def get_file_info(self, session_id: str, file_id: str) -> Optional[FileInf
287287 if not metadata :
288288 return None
289289
290- # Parse last_used_at if present
291- last_used_at = None
292- if metadata .get ("last_used_at" ):
293- try :
294- last_used_at = datetime .fromisoformat (metadata ["last_used_at" ])
295- except (ValueError , TypeError ):
296- pass
297-
298290 return FileInfo (
299291 file_id = file_id ,
300292 filename = metadata ["filename" ],
301293 size = metadata ["size" ],
302294 content_type = metadata ["content_type" ],
303295 created_at = metadata ["created_at" ],
304296 path = metadata ["path" ],
305- execution_id = metadata .get ("execution_id" ),
306- state_hash = metadata .get ("state_hash" ),
307- last_used_at = last_used_at ,
308297 )
309298
310299 async def list_files (self , session_id : str ) -> List [FileInfo ]:
@@ -454,17 +443,13 @@ async def store_execution_output_file(
454443 session_id : str ,
455444 filename : str ,
456445 content : bytes ,
457- execution_id : Optional [str ] = None ,
458- state_hash : Optional [str ] = None ,
459446 ) -> str :
460447 """Store a file generated during code execution.
461448
462449 Args:
463450 session_id: Session identifier
464451 filename: Name of the file
465452 content: File content as bytes
466- execution_id: Optional ID of the execution that created this file
467- state_hash: Optional SHA256 hash of the Python state at creation time
468453
469454 Returns:
470455 The generated file_id
@@ -496,7 +481,6 @@ async def store_execution_output_file(
496481
497482 now = datetime .utcnow ()
498483
499- # Store metadata including state restoration fields
500484 metadata = {
501485 "file_id" : file_id ,
502486 "filename" : filename ,
@@ -509,13 +493,6 @@ async def store_execution_output_file(
509493 "type" : "output" , # Mark as execution output
510494 }
511495
512- # Add state restoration fields if provided
513- if execution_id :
514- metadata ["execution_id" ] = execution_id
515- if state_hash :
516- metadata ["state_hash" ] = state_hash
517- metadata ["last_used_at" ] = now .isoformat ()
518-
519496 await self ._store_file_metadata (session_id , file_id , metadata )
520497
521498 logger .debug (
@@ -822,84 +799,11 @@ async def cleanup_orphan_objects(self, batch_limit: int = 1000) -> int:
822799 logger .error ("Orphan MinIO objects cleanup failed" , error = str (e ))
823800 return 0
824801
825- async def get_file_state_hash (self , session_id : str , file_id : str ) -> Optional [str ]:
826- """Get the state hash associated with a file.
827-
828- Args:
829- session_id: Session identifier
830- file_id: File identifier
831-
832- Returns:
833- SHA256 hash of the state when this file was last used, or None
834- """
835- try :
836- metadata_key = self .get_file_metadata_key (session_id , file_id )
837- state_hash = await self .redis_client .hget (metadata_key , "state_hash" )
838- return state_hash
839- except Exception as e :
840- logger .error (
841- "Failed to get file state hash" ,
842- error = str (e ),
843- session_id = session_id ,
844- file_id = file_id ,
845- )
846- return None
847-
848- async def update_file_state_hash (
849- self ,
850- session_id : str ,
851- file_id : str ,
852- state_hash : str ,
853- execution_id : Optional [str ] = None ,
854- ) -> bool :
855- """Update the state hash for a file (called when file is used in execution).
856-
857- Args:
858- session_id: Session identifier
859- file_id: File identifier
860- state_hash: New SHA256 hash of the Python state
861- execution_id: Optional ID of the execution that used this file
862-
863- Returns:
864- True if update was successful
865- """
866- try :
867- metadata_key = self .get_file_metadata_key (session_id , file_id )
868- now = datetime .utcnow ().isoformat ()
869-
870- # Update multiple fields atomically
871- updates = {
872- "state_hash" : state_hash ,
873- "last_used_at" : now ,
874- }
875- if execution_id :
876- updates ["execution_id" ] = execution_id
877-
878- await self .redis_client .hset (metadata_key , mapping = updates )
879-
880- logger .debug (
881- "Updated file state hash" ,
882- session_id = session_id [:12 ],
883- file_id = file_id ,
884- state_hash = state_hash [:12 ],
885- )
886- return True
887- except Exception as e :
888- logger .error (
889- "Failed to update file state hash" ,
890- error = str (e ),
891- session_id = session_id ,
892- file_id = file_id ,
893- )
894- return False
895-
896802 async def update_file_content (
897803 self ,
898804 session_id : str ,
899805 file_id : str ,
900806 content : bytes ,
901- state_hash : Optional [str ] = None ,
902- execution_id : Optional [str ] = None ,
903807 ) -> bool :
904808 """Update the content of an existing file.
905809
@@ -910,8 +814,6 @@ async def update_file_content(
910814 session_id: Session identifier
911815 file_id: File identifier
912816 content: New file content as bytes
913- state_hash: Optional SHA256 hash of the Python state
914- execution_id: Optional ID of the execution that modified this file
915817
916818 Returns:
917819 True if update was successful
@@ -955,15 +857,9 @@ async def update_file_content(
955857 )
956858
957859 # Update metadata
958- now = datetime .utcnow ().isoformat ()
959860 updates = {
960861 "size" : len (content ),
961- "last_used_at" : now ,
962862 }
963- if state_hash :
964- updates ["state_hash" ] = state_hash
965- if execution_id :
966- updates ["execution_id" ] = execution_id
967863
968864 metadata_key = self .get_file_metadata_key (session_id , file_id )
969865 await self .redis_client .hset (metadata_key , mapping = updates )
0 commit comments