Skip to content
Snippets Groups Projects
Commit 1096bfff authored by Blake Fitch's avatar Blake Fitch
Browse files

add replace_existing flag and function to confirmed_put()

parent 2cd63f06
No related branches found
Tags STAG-2024-06-23-13-13-11
No related merge requests found
......@@ -350,11 +350,12 @@ def streaming_transfer_file_to_object( args ):
return rc, hash_digest256, hash_digest512, transfer_size
# Returns None or the data_object irods ref.
def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None, datatype=None, block_size=(2**28) ):
def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None, datatype=None, block_size=(2**28), replace_existing=None ):
logging.debug( "file_pathname: " + file_pathname
+ " new_obj_ipath: " + new_obj_ipath
+ " datatype: " + datatype
+ " block_size: " + str( block_size ) )
+ " block_size: " + str( block_size )
+ " replace_existing " + str( replace_existing) )
# NOTE: this routine uploades the file as a temporary iRODS object.
# Common sense suggests checking if the objct already exsists, a rare condition first.
......@@ -504,6 +505,14 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
logging.debug( "file " + file_pathname + " in place at ipath " + new_obj_ipath )
if existing_obj != None and replace_existing:
logging.warning( f"replace_existing flag set. Removing old data object. ipath: {dup_ipath}" )
try:
dup_obj = irods_sesh.data_objects.get( dup_ipath )
dup_obj.unlink(force=True)
except Exception as ex:
logging.warning( "Failed remove dup when remove_existing flag set. ipath: {dup_ipath} ex: {ex} " )
new_obj = None
try:
new_obj = irods_sesh.data_objects.get( new_obj_ipath )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment