summaryrefslogtreecommitdiff
path: root/modules/update/update.manager.inc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/update/update.manager.inc')
-rw-r--r--modules/update/update.manager.inc44
1 files changed, 13 insertions, 31 deletions
diff --git a/modules/update/update.manager.inc b/modules/update/update.manager.inc
index 4f55b1b5b..35b292905 100644
--- a/modules/update/update.manager.inc
+++ b/modules/update/update.manager.inc
@@ -1,5 +1,4 @@
<?php
-// $Id$
/**
* @file
@@ -644,8 +643,11 @@ function update_manager_install_form_submit($form, &$form_state) {
form_set_error($field, t('Provided archive contains no files.'));
return;
}
- // Unfortunately, we can only use the directory name for this. :(
- $project = drupal_substr($files[0], 0, -1);
+
+ // Unfortunately, we can only use the directory name to determine the project
+ // name. Some archivers list the first file as the directory (i.e., MODULE/)
+ // and others list an actual file (i.e., MODULE/README.TXT).
+ $project = strtok($files[0], '/\\');
$archive_errors = update_manager_archive_verify($project, $local_cache, $directory);
if (!empty($archive_errors)) {
@@ -729,26 +731,6 @@ function update_manager_install_form_submit($form, &$form_state) {
*/
/**
- * Return the directory where update archive files should be extracted.
- *
- * If the directory does not already exist, attempt to create it.
- *
- * @return
- * The full path to the temporary directory where update file archives
- * should be extracted.
- */
-function _update_manager_extract_directory() {
- $directory = &drupal_static(__FUNCTION__, '');
- if (empty($directory)) {
- $directory = 'temporary://update-extraction';
- if (!file_exists($directory)) {
- mkdir($directory);
- }
- }
- return $directory;
-}
-
-/**
* Unpack a downloaded archive file.
*
* @param string $project
@@ -771,8 +753,12 @@ function update_manager_archive_extract($file, $directory) {
// old files mixed with the new files (e.g. in cases where files were removed
// from a later release).
$files = $archiver->listContents();
- // Unfortunately, we can only use the directory name for this. :(
- $project = drupal_substr($files[0], 0, -1);
+
+ // Unfortunately, we can only use the directory name to determine the project
+ // name. Some archivers list the first file as the directory (i.e., MODULE/)
+ // and others list an actual file (i.e., MODULE/README.TXT).
+ $project = strtok($files[0], '/\\');
+
$extract_location = $directory . '/' . $project;
if (file_exists($extract_location)) {
file_unmanaged_delete_recursive($extract_location);
@@ -823,13 +809,9 @@ function update_manager_file_get($url) {
}
// Check the cache and download the file if needed.
- $cache_directory = 'temporary://update-cache';
+ $cache_directory = _update_manager_cache_directory();
$local = $cache_directory . '/' . basename($parsed_url['path']);
- if (!file_exists($cache_directory)) {
- mkdir($cache_directory);
- }
-
if (!file_exists($local) || update_delete_file_if_stale($local)) {
return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE);
}
@@ -849,7 +831,7 @@ function update_manager_file_get($url) {
* The short name of the project to download.
* @param string $url
* The URL to download a specific project release archive file.
- * @param array &$context
+ * @param array $context
* Reference to an array used for BatchAPI storage.
*
* @see update_manager_download_page()