You are here

function update_manager_file_get in Drupal 7

Same name and namespace in other branches
  1. 8 core/modules/update/update.manager.inc \update_manager_file_get()
  2. 9 core/modules/update/update.manager.inc \update_manager_file_get()
  3. 10 core/modules/update/update.manager.inc \update_manager_file_get()

Copies a file from the specified URL to the temporary directory for updates.

Returns the local path if the file has already been downloaded.

Parameters

$url: The URL of the file on the server.

Return value

string Path to local file.

Related topics

2 calls to update_manager_file_get()
update_manager_batch_project_get in modules/update/update.manager.inc
Implements callback_batch_operation().
update_manager_install_form_submit in modules/update/update.manager.inc
Form submission handler for update_manager_install_form().

File

modules/update/update.manager.inc, line 831
Administrative screens and processing functions of the Update Manager module.

Code

function update_manager_file_get($url) {
  $parsed_url = parse_url($url);
  $remote_schemes = array(
    'http',
    'https',
    'ftp',
    'ftps',
    'smb',
    'nfs',
  );
  if (!in_array($parsed_url['scheme'], $remote_schemes)) {

    // This is a local file, just return the path.
    return drupal_realpath($url);
  }

  // Check the cache and download the file if needed.
  $cache_directory = _update_manager_cache_directory();
  $local = $cache_directory . '/' . drupal_basename($parsed_url['path']);
  if (!file_exists($local) || update_delete_file_if_stale($local)) {
    return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE);
  }
  else {
    return $local;
  }
}