You are here

function _drush_views_data_export_batch_finished in Views data export 7.4

Same name and namespace in other branches
  1. 6.3 views_data_export.drush.inc \_drush_views_data_export_batch_finished()
  2. 6 views_data_export.drush.inc \_drush_views_data_export_batch_finished()
  3. 6.2 views_data_export.drush.inc \_drush_views_data_export_batch_finished()
  4. 7 views_data_export.drush.inc \_drush_views_data_export_batch_finished()
  5. 7.3 views_data_export.drush.inc \_drush_views_data_export_batch_finished()

Get's called at the end of the drush batch process that generated our export

1 string reference to '_drush_views_data_export_batch_finished'
views_data_export_views_data_export_batch_alter in ./views_data_export.drush.inc
Implementation of hook_views_data_export_batch_alter()

File

./views_data_export.drush.inc, line 262

Code

function _drush_views_data_export_batch_finished($eid, $output_file, &$context) {

  // Fetch export info
  $export = views_data_export_get($eid);

  // Perform cleanup
  $view = views_data_export_view_retrieve($eid);
  $view
    ->set_display($export->view_display_id);
  $view->display_handler->batched_execution_state = $export;
  $view->display_handler
    ->remove_index();

  // Get path to temp file
  $temp_file = $view->display_handler
    ->outputfile_path();

  // Copy file over
  if (@drush_op('copy', $temp_file, $output_file)) {
    drush_log("Data export saved to " . $output_file, 'success');
  }
  else {
    drush_set_error('VIEWS_DATA_EXPORT_COPY_ERROR', dt("The file could not be copied to the selected destination"));
  }
}