public static function getPatch(array $patch)
 {
     static $cache = array();
     if (!isset($cache[$patch['url']])) {
         if (!empty($patch['local'])) {
             if (is_file($patch['url']) && filesize($patch['url'])) {
                 $cache[$patch['url']] = $patch['url'];
             } else {
                 throw new Exception("Unable to read patch from local path {$patch['url']}.");
             }
         } elseif (drush_get_option('no-cache')) {
             $temp_file = drush_tempnam('drush_patchfile_', NULL, '.patch');
             $cache[$patch['url']] = static::downloadPatch($patch['url'], $temp_file);
         } else {
             $cache_file = drush_directory_cache('patchfile') . '/' . md5($patch['url']) . '.patch';
             if (is_file($cache_file) && filectime($cache_file) > $_SERVER['REQUEST_TIME'] - DRUSH_CACHE_LIFETIME_DEFAULT) {
                 drush_log(dt('Remote patch URL @url fetched from cache file @cache.', array('@url' => $patch['url'], '@cache' => $cache_file)));
                 $cache[$patch['url']] = $cache_file;
             } else {
                 $cache[$patch['url']] = static::downloadPatch($patch['url'], $cache_file);
             }
         }
     }
     return $cache[$patch['url']];
 }
示例#2
0
 function cacheDirectory($bin = NULL)
 {
     $bin = $bin ? $bin : $this->bin;
     return drush_directory_cache($bin);
 }