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

change confirmed_put() to use a timestamped temp file for initial upload...

change confirmed_put() to use a timestamped temp file for initial upload rather than just blah.IMA_tmp
parent 82c53ef9
No related branches found
No related tags found
No related merge requests found
......@@ -361,22 +361,30 @@ def confirmed_put( irods_sesh, file, new_obj_ipath, metadata_dict=None, datatype
+ " ipath: " + new_obj_ipath )
return new_obj # will not upload since the object and metadata should now match.
# Expect to be able to put now.
# The file is new and will be uploaded here along with metadata.
new_obj_ipath_tmp = new_obj_ipath + "_tmp"
# Check if the temp obj exists
try:
options = {} # shouldn't care about the checksum {kw.VERIFY_CHKSUM_KW: ''}
new_obj = irods_sesh.data_objects.get( new_obj_ipath_tmp, **options )
irods_sesh.data_objects.unlink( new_obj_ipath_tmp, force = True )
logging.error( "new_obj tmp file existed and has been deleted. This means we've tried to upload here before and failed."
+ " new_obj_ipath_tmp " + new_obj_ipath_tmp )
except Exception as ex:
logging.debug( "Failed to get new_obj_ipath_tmp. (OK because we expect to create it.)"
+ " tmp ipath: " + new_obj_ipath_tmp
+ " ex: " + str(ex) )
# !! This code had a problem with a network error leaving table row for object
# !! with data_is_dirty set wrong. Table r_data_main
## Expect to be able to put now.
## The file is new and will be uploaded here along with metadata.
#new_obj_ipath_tmp = new_obj_ipath + "_tmp"
#
## Check if the temp obj exists
#try:
# options = {} # shouldn't care about the checksum {kw.VERIFY_CHKSUM_KW: ''}
# new_obj = irods_sesh.data_objects.get( new_obj_ipath_tmp, **options )
# # When there has not been an exception, delete the old tmp object
# irods_sesh.data_objects.unlink( new_obj_ipath_tmp, force = True )
# logging.error( "new_obj tmp file existed and has been deleted. This means we've tried to upload here before and failed."
# + " new_obj_ipath_tmp " + new_obj_ipath_tmp )
#except Exception as ex:
# logging.debug( "Failed to get new_obj_ipath_tmp. (OK because we expect to create it.)"
# + " tmp ipath: " + new_obj_ipath_tmp
# + " ex: " + str(ex) )
#
# 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.
# Cleanup will need to be done elsewhere.
new_obj_ipath_tmp = new_obj_ipath + ".part." + datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S.%fZ%z")
logging.debug("Uploading file: " + file + " to tmp ipath: " + new_obj_ipath_tmp )
try:
......
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