You are here

function drush_stage_file_proxy_dl in Stage File Proxy 7

Same name and namespace in other branches
  1. 8 stage_file_proxy.drush8.inc \drush_stage_file_proxy_dl()

Download all managed files from the origin.

File

./stage_file_proxy.drush.inc, line 23
Contains drush commands.

Code

function drush_stage_file_proxy_dl() {
  $origin = variable_get('stage_file_proxy_origin');
  if (empty($origin)) {
    drush_print(dt('Configure stage_file_proxy_origin variable in your settings.php.'), 'error');
    return;
  }
  $query = db_select('file_managed', 'fm');
  $query
    ->fields('fm', array(
    'uri',
  ));
  $query
    ->orderBy('fm.fid', 'DESC');
  $results = $query
    ->execute()
    ->fetchCol();
  $got_files_number = 0;
  foreach ($results as $uri) {
    if (stage_file_proxy_process_file_uri($uri)) {
      if (drush_get_option('verbose', FALSE)) {
        drush_print(dt('Downloaded @file.', array(
          '@file' => $uri,
        )));
      }
      $got_files_number++;
    }
  }
  drush_print(dt('@got_files_number downladed files.', array(
    '@got_files_number' => $got_files_number,
  )));
}