@@ -103,7 +103,14 @@ def doWriteBack(source, destination):
103103
104104def doStashCpSingle (sourceFile , destination , cache , debug = False ):
105105
106- #cache=get_best_stashcache()
106+
107+ # Check if the desitnation is a protocol like stash:///user/blah
108+ if destination .startswith ("stash://" ):
109+ # Source file exists, must be a writeback
110+ return doWriteBack (sourceFile , destination )
111+
112+ if not cache :
113+ cache = get_best_stashcache ()
107114 logging .debug ("Using Cache %s" , cache )
108115
109116 sitename = os .environ .setdefault ("OSG_SITE_NAME" , "siteNotFound" )
@@ -116,12 +123,8 @@ def doStashCpSingle(sourceFile, destination, cache, debug=False):
116123 payload ['filename' ] = sourceFile
117124 payload ['sitename' ] = sitename
118125 payload .update (parse_job_ad ())
119-
120- # Check if the desitnation is a protocol like stash:///user/blah
121- if destination .startswith ("stash://" ):
122- # Source file exists, must be a writeback
123- return doWriteBack (sourceFile , destination )
124-
126+
127+
125128 # Calculate the starting time
126129 start1 = int (time .time ()* 1000 )
127130
@@ -448,14 +451,11 @@ def main():
448451 source = opts [0 ]
449452 destination = opts [1 ]
450453
451-
454+ cache = None
452455 # Check for manually entered cache to use
453456 if args .cache and len (args .cache ) > 0 :
454457 cache = args .cache
455- else :
456- cache = get_best_stashcache ()
457-
458-
458+
459459 if not args .recursive :
460460 result = doStashCpSingle (sourceFile = source , destination = destination , cache = cache , debug = args .debug )
461461 else :
0 commit comments