You are here

function fancy_file_delete_drush_batch_delete_process in Fancy File Delete 7

Same name and namespace in other branches
  1. 2.0.x fancy_file_delete.drush.inc \fancy_file_delete_drush_batch_delete_process()

Run fancy file delete.

1 string reference to 'fancy_file_delete_drush_batch_delete_process'
fancy_file_delete_drush_command in ./fancy_file_delete.drush.inc
Implements hook_drush_command().

File

./fancy_file_delete.drush.inc, line 38

Code

function fancy_file_delete_drush_batch_delete_process($file_list) {
  $operations = array();

  // Prompt user for confirmation.
  $confirm = drush_confirm('WARNING! Are you sure you want to delete these files?');
  if (!$confirm) {
    drush_user_abort();
    return;
  }

  // Initialize our batch operations.
  $files = explode(',', $file_list);
  $force = drush_get_option('force', FALSE);
  foreach ($files as $file) {
    $operations[] = array(
      'fancy_file_delete_batch_delete',
      array(
        $file,
        $force,
      ),
    );
  }

  // Create our batch.
  $batch = array(
    'operations' => $operations,
    'title' => 'Deleting files.',
    'init_message' => 'Initializing.',
    'error_message' => 'An error occurred during file deletion.',
    'finished' => 'fancy_file_delete_batch_delete_finished',
    'file' => drupal_get_path('module', 'fancy_file_delete') . '/includes/fancy_file_delete.batch_delete.inc',
  );
  batch_set($batch);
  $batch =& batch_get();
  $batch['progressive'] = FALSE;

  // Start the process.
  drush_backend_batch_process();
}