Skip to content

Commit 4cf6fcc

Browse files
Merge pull request #87 from matyasselmeci/wip/filesize
Make file size query failure not fatal
2 parents 59645a3 + 577cbe4 commit 4cf6fcc

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

bin/stashcp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,15 @@ def doStashCpSingle(sourceFile, destination, debug=False):
180180
xrdcp_version = subprocess.Popen(['echo $(xrdcp -V 2>&1)'], stdout=subprocess.PIPE, shell=True).communicate()[0][:-1]
181181
try:
182182
fileSize = int(re.findall(r"Size: \d+", xrdfs_stdout)[0].split(": ")[1])
183-
except Exception as e:
184-
sys.stderr.write("Unable to find size of file\n")
183+
logging.debug("Size of the file %s is %s", sourceFile, fileSize)
184+
payload['filesize'] = fileSize
185+
except (ValueError, IndexError) as e:
186+
sys.stderr.write("Unable to find size of file from the origin\n")
185187
print str(xrdfs_stdout)
186188
sys.stderr.write(str(xrdfs_stderr))
187189
sys.stderr.write("\n")
188-
return 1
189-
logging.debug("Size of the file %s is %s", sourceFile, str(fileSize))
190190

191191
payload['xrdcp_version'] = xrdcp_version
192-
payload['filesize'] = fileSize
193192

194193
end1=int(time.time()*1000)
195194
payload['end1']=end1
@@ -222,6 +221,8 @@ def doStashCpSingle(sourceFile, destination, debug=False):
222221
payload['status']=status
223222
payload['tries']=tries
224223
payload['cache']=nearest_cache
224+
if 'filesize' not in payload:
225+
payload['filesize']=dlSz
225226
es_send(payload)
226227

227228
else: #pull from origin
@@ -250,6 +251,8 @@ def doStashCpSingle(sourceFile, destination, debug=False):
250251
payload['start3']=start3
251252
payload['end3']=end3
252253
payload['cache']=nearest_cache
254+
if 'filesize' not in payload:
255+
payload['filesize']=dlSz
253256
es_send(payload)
254257
if xrd_exit == '0':
255258
return 0

0 commit comments

Comments
 (0)