@@ -568,8 +568,6 @@ def revision_create(ctx: rule.Context, print_verbose: bool, data_id: str, resour
568568
569569 :returns: True / False as an indication whether a revision was successfully created
570570 """
571- revision_created = False
572-
573571 # Retrieve properties of the data object
574572 data_properties = data_object .get_properties (ctx , data_id , resource )
575573
@@ -625,23 +623,32 @@ def revision_create(ctx: rule.Context, print_verbose: bool, data_id: str, resour
625623 try :
626624 # Workaround the PREP deadlock issue: Restrict threads to 1.
627625 data_object .copy (ctx , path , rev_path , True )
628-
629- revision_created = True
630-
631- # Add original metadata to revision data object.
632- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_data_id" , data_id )
633- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_path" , path )
634- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_coll_name" , parent )
635- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_data_name" , basename )
636- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_data_owner_name" , data_owner )
637- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_coll_id" , coll_id )
638- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_modify_time" , modify_time )
639- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_group_name" , group_name )
640- avu .set_on_data (ctx , rev_path , constants .UUORGMETADATAPREFIX + "original_filesize" , data_size )
641626 except msi .Error as e :
642627 log .write (ctx , 'ERROR - The file could not be copied: {}' .format (str (e )))
628+ return False
643629
644- return revision_created
630+ # Add original metadata to revision data object.
631+ prefix = constants .UUORGMETADATAPREFIX
632+ operations = {
633+ "entity_name" : rev_path ,
634+ "entity_type" : "data_object" ,
635+ "operations" : [
636+ {"operation" : "add" , "attribute" : f"{ prefix } original_data_id" , "value" : data_id , "units" : "" },
637+ {"operation" : "add" , "attribute" : f"{ prefix } original_path" , "value" : path , "units" : "" },
638+ {"operation" : "add" , "attribute" : f"{ prefix } original_coll_name" , "value" : parent , "units" : "" },
639+ {"operation" : "add" , "attribute" : f"{ prefix } original_data_name" , "value" : basename , "units" : "" },
640+ {"operation" : "add" , "attribute" : f"{ prefix } original_data_owner_name" , "value" : data_owner , "units" : "" },
641+ {"operation" : "add" , "attribute" : f"{ prefix } original_coll_id" , "value" : coll_id , "units" : "" },
642+ {"operation" : "add" , "attribute" : f"{ prefix } original_modify_time" , "value" : modify_time , "units" : "" },
643+ {"operation" : "add" , "attribute" : f"{ prefix } original_group_name" , "value" : group_name , "units" : "" },
644+ {"operation" : "add" , "attribute" : f"{ prefix } original_filesize" , "value" : data_size , "units" : "" },
645+ ]
646+ }
647+ if avu .apply_atomic_operations (ctx , operations ):
648+ return True
649+
650+ log .write (ctx , f"ERROR - The revision metadata could not be added to: { rev_path } " )
651+ return False
645652
646653
647654def revision_cleanup_scan_revision_objects (ctx : rule .Context , revision_list : List ) -> List :
0 commit comments