227
228
dest->SetSecure(false);
228
229
dest->Passive(true);
231
// set X509* for 3rd party tools which need it (eg GFAL)
232
SetEnv("X509_USER_PROXY", source_cfg.ProxyPath());
233
if (!source_cfg.CACertificatesDirectory().empty()) SetEnv("X509_CERT_DIR", source_cfg.CACertificatesDirectory());
234
// those tools also use hostcert by default if the user is root...
236
SetEnv("X509_USER_CERT", source_cfg.ProxyPath());
237
SetEnv("X509_USER_KEY", source_cfg.ProxyPath());
230
240
// set signal handlers
231
241
signal(SIGTERM, sig_shutdown);
232
242
signal(SIGINT, sig_shutdown);
273
283
DataStaging::DTRErrorStatus::LOCAL_FILE_ERROR,
274
284
DataStaging::DTRErrorStatus::ERROR_SOURCE,
275
285
std::string("Failed reading from source: ")+source->CurrentLocation().str()+
276
" : "+source->GetFailureReason().GetDesc()+": "+source_st.GetDesc(),
286
" : "+std::string(source_st),
287
297
DataStaging::DTRErrorStatus::LOCAL_FILE_ERROR,
288
298
DataStaging::DTRErrorStatus::ERROR_DESTINATION,
289
299
std::string("Failed writing to destination: ")+dest->CurrentLocation().str()+
290
" : "+dest->GetFailureReason().GetDesc()+": "+dest_st.GetDesc(),
300
" : "+std::string(dest_st),
334
344
// Error at source or destination
335
345
if(source_failed || !source_st) {
346
std::string err("Failed reading from source: "+source->CurrentLocation().str());
347
// If error reported in read callback, use that instead
348
if (source->GetFailureReason() != DataStatus::UnknownError) source_st = source->GetFailureReason();
349
if (!source_st) err += " : " + std::string(source_st);
336
350
ReportStatus(DataStaging::DTRStatus::TRANSFERRED,
337
351
(source_url.Protocol() != "file") ?
338
(!source_st && source_st.Retryable() ?
352
(((!source_st && source_st.Retryable()) || buffer.speed.transferred_size() > 0) ?
339
353
DataStaging::DTRErrorStatus::TEMPORARY_REMOTE_ERROR :
340
354
DataStaging::DTRErrorStatus::PERMANENT_REMOTE_ERROR) :
341
355
DataStaging::DTRErrorStatus::LOCAL_FILE_ERROR,
342
356
DataStaging::DTRErrorStatus::ERROR_SOURCE,
343
std::string("Failed reading from source: ")+source->CurrentLocation().str()+
344
" : "+source->GetFailureReason().GetDesc()+": "+source_st.GetDesc(),
345
358
buffer.speed.transferred_size(),
346
359
GetFileSize(*source,*dest));
349
362
if(dest_failed || !dest_st) {
363
std::string err("Failed writing to destination: "+dest->CurrentLocation().str());
364
// If error reported in write callback, use that instead
365
if (dest->GetFailureReason() != DataStatus::UnknownError) dest_st = dest->GetFailureReason();
366
if (!dest_st) err += " : " + std::string(dest_st);
350
367
ReportStatus(DataStaging::DTRStatus::TRANSFERRED,
351
368
(dest_url.Protocol() != "file") ?
352
(!dest_st && dest_st.Retryable() ?
369
(((!dest_st && dest_st.Retryable()) || buffer.speed.transferred_size() > 0) ?
353
370
DataStaging::DTRErrorStatus::TEMPORARY_REMOTE_ERROR :
354
371
DataStaging::DTRErrorStatus::PERMANENT_REMOTE_ERROR) :
355
372
DataStaging::DTRErrorStatus::LOCAL_FILE_ERROR,
356
373
DataStaging::DTRErrorStatus::ERROR_DESTINATION,
357
std::string("Failed writing to destination: ")+dest->CurrentLocation().str()+
358
" : "+dest->GetFailureReason().GetDesc()+": "+dest_st.GetDesc(),
359
375
buffer.speed.transferred_size(),
360
376
GetFileSize(*source,*dest));
406
422
eof_reached = false; // TODO general error flag is better than this
423
// Delete destination
424
if (!dest->Remove().Passed()) {
425
logger.msg(WARNING, "Failed cleaning up destination %s", dest->GetURL().str());
409
429
logger.msg(INFO, "Calculated transfer checksum %s matches source checksum", calc_csum);