function acquia_migrate_batch_transmit in Acquia Connector 7.2
Same name and namespace in other branches
- 6.2 acquia_agent/acquia_agent.migrate.inc \acquia_migrate_batch_transmit()
1 string reference to 'acquia_migrate_batch_transmit'
- acquia_agent_migrate_form_submit in acquia_agent/
acquia_agent.pages.inc - Submit handler for Acquia Cloud migrate button.
File
- acquia_agent/
acquia_agent.migrate.inc, line 246 - Upload to Acquia Cloud.
Code
function acquia_migrate_batch_transmit($migration, &$context) {
_acquia_migrate_process_setup();
// Latest migration is in $context.
if (!empty($context['results']['migration'])) {
$migration = $context['results']['migration'];
variable_set('acquia_agent_cloud_migration', $migration);
}
// Check for error and abort if appropriate.
if (empty($migration) || $migration['error'] !== FALSE) {
$context['message'] = t('Encountered error, aborting migration.');
$context['finished'] = 1;
return;
}
// First call.
if (empty($context['sandbox'])) {
$context['sandbox']['position'] = 0;
$size = filesize($migration['tar_file']);
$context['sandbox']['size'] = $size;
$migration['request_params']['file_size'] = $size;
$migration['request_params']['hash'] = md5_file($migration['tar_file']);
$migration['file_name'] = basename($migration['tar_file']);
}
// Set to 0.5 MB.
$length = 1024 * 1024 / 2;
$position = _acquia_migrate_transmit_chunk($migration, $context['sandbox']['position'], $length);
$context['sandbox']['position'] = $position;
// Store migration in results so it can be used by next operation.
$context['results']['migration'] = $migration;
if ($context['sandbox']['position'] !== FALSE) {
$context['message'] = t('Uploading archive. Transferred !pos of !size bytes.', array(
'!pos' => $context['sandbox']['position'],
'!size' => $context['sandbox']['size'],
));
$finished = $context['sandbox']['position'] / $context['sandbox']['size'];
if ($finished !== 1 && _acquia_migrate_broken_rounding() && $finished > 0.98) {
// In case this version of Drupal 7 is lower than 7.4
// force finished to 98% for remaining chunks due to rounding error
// in Batch API. http://drupal.org/node/1089472
$finished = 0.98;
}
$context['finished'] = $finished;
}
else {
$context['finished'] = 1;
}
}