diff --git modules/update/update.manager.inc modules/update/update.manager.inc index 4f55b1b..636aa97 100644 --- modules/update/update.manager.inc +++ modules/update/update.manager.inc @@ -729,25 +729,62 @@ function update_manager_install_form_submit($form, &$form_state) { */ /** + * Return a short unique identifier for this Drupal installation. + * + * @return + * An eight character string uniquely identifying this Drupal installation. + */ +function _update_manager_unique_identifier() { + $id = &drupal_static(__FUNCTION__, ''); + if (empty($id)) { + $id = substr(hash('sha256', drupal_get_hash_salt()), 0, 8); + } + return $id; +} + +/** * Return the directory where update archive files should be extracted. * - * If the directory does not already exist, attempt to create it. + * @param $create + * If TRUE, attempt to create the directory if it does not already exist. * * @return * The full path to the temporary directory where update file archives * should be extracted. */ -function _update_manager_extract_directory() { +function _update_manager_extract_directory($create = TRUE) { + $directory = &drupal_static(__FUNCTION__, ''); + if (empty($directory)) { + $directory = 'temporary://update-extraction-' . _update_manager_unique_identifier(); + if ($create && !file_exists($directory)) { + mkdir($directory); + } + } + return $directory; +} + +/** + * Return the directory where update archive files should be cached. + * + * @param $create + * If TRUE, attempt to create the directory if it does not already exist. + * + * @return + * The full path to the temporary directory where update file archives + * should be cached. + */ +function _update_manager_cache_directory($create = TRUE) { $directory = &drupal_static(__FUNCTION__, ''); if (empty($directory)) { - $directory = 'temporary://update-extraction'; - if (!file_exists($directory)) { + $directory = 'temporary://update-cache-' . _update_manager_unique_identifier(); + if ($create && !file_exists($directory)) { mkdir($directory); } } return $directory; } + /** * Unpack a downloaded archive file. * @@ -823,13 +860,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); } diff --git modules/update/update.module modules/update/update.module index c5551e2..ed9b646 100644 --- modules/update/update.module +++ modules/update/update.module @@ -861,10 +861,11 @@ function update_flush_caches() { * Clear the temporary files and directories based on file age from disk. */ function update_clear_update_disk_cache() { - // List of update module cache directories. + // List of update module cache directories. Do not create the directories if + // they do not exist. $directories = array( - 'temporary://update-cache', - 'temporary://update-extraction', + _update_manager_cache_directory(FALSE), + _update_manager_extract_directory(FALSE), ); // Search for files and directories in base folder only without recursion.