update_manager_file_get

Versions
7
update_manager_file_get($url)

Copies a file from $url to the temporary directory for updates.

If the file has already been downloaded, returns the the local path.

Parameters

$url The URL of the file on the server.

Return value

string Path to local file.

Related topics

▾ 2 functions call update_manager_file_get()

update_manager_batch_project_get in modules/update/update.manager.inc
Batch operation: download, unpack, and verify a project.
update_manager_install_form_submit in modules/update/update.manager.inc
Handle form submission when installing new projects via the update manager.

Code

modules/update/update.manager.inc, line 720

<?php
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.
  $local = 'temporary://update-cache/' . basename($parsed_url['path']);
  $cache_directory = DRUPAL_ROOT . '/' . file_directory_path('temporary') . '/update-cache/';

  if (!file_exists($cache_directory)) {
    mkdir($cache_directory);
  }
  
  if (!file_exists($local)) {
    return system_retrieve_file($url, $local);
  }
  else {
    return $local;
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.