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

separate case of skipping zero len file from removing (unlinking) preexisting...

separate case of skipping zero len file from removing (unlinking) preexisting iRODS object for replace_existing flag
parent 881777c8
No related branches found
No related tags found
No related merge requests found
......@@ -391,14 +391,18 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
logging.error( f"FATAL: Failed to get size of file to upload. file_pathname: {file_pathname} ex: {ex}" )
raise
if upload_file_size == 0 and existing_obj != None and replace_existing and skip_on_zero_len :
logging.warning( f"got zero len file with replace_existing -- removing current data object. ipath: {new_obj_ipath}" )
try:
existing_obj.unlink(force=True)
return 0
except Exception as ex:
logging.warning( "Failed remove zero line file on replace_existing and skip_on_zero_len. ipath: {new_obj_ipath} ex: {ex} " )
raise
# Return if zero sized objects are to be discarded. Check if an existing object needs to be removed.
if upload_file_size == 0 and skip_on_zero_len:
if existing_obj != None and replace_existing:
logging.warning( f"Got zero len file. Removing existing iRODS obj. file_pathname: {file_pathname} ipath: {new_obj_ipath}" )
try:
existing_obj.unlink(force=True)
except Exception as ex:
logging.error( "Failed remove existing zero line file on replace_existing and skip_on_zero_len. ipath: {new_obj_ipath} ex: {ex} " )
raise
else:
logging.debug( f"Got zero len file with skip_on_zero_len set. Returning. file_pathname: {file_pathname} ipath: {new_obj_ipath}" )
return 0
# Make a timestamped partial tmp file name which, if the upload somehow fails here, will be left behind
# Hopefully this does not happen much, but we have seen at least on case so far.
......
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