示例#1
0
function del_cache($ctype = '', $m = '', $n = '', $sid = 0)
{
    $cacdir = cache_dir($ctype, $sid);
    $cacname = cache_name($ctype, $m, $n);
    @unlink($cacdir . '/' . $cacname . '.cac.php');
    return;
}
示例#2
0
/**
 *	Get a list of Makefile targets for a (template) repository
 *	@param $param[1] (template) repository
 */
function api_get_repo_targets($param = array())
{
    $repo = $param[1];
    $cached = get_repo_for_reading($repo);
    if ($cached === false) {
        router_error_404('Cannot get ' . $repo);
    }
    $targets = make_get_targets(cache_dir($cached));
    if ($targets === false) {
        router_error_500('Cannot get Makefile targets for ' . $repo);
    }
    $ignore_targets = config('ignore_targets', array());
    $target_descriptions = config('target_descriptions', array());
    $default_target = config('default_target');
    $ret = array();
    foreach ($targets as $target) {
        // filter certain targets according to ignore_targets config
        if (in_array($target, $ignore_targets)) {
            continue;
        }
        $tmp = array('target' => $target);
        $tmp['description'] = isset($target_descriptions[$target]) ? $target_descriptions[$target] : $target;
        $tmp['default'] = $target === $default_target;
        $ret[] = $tmp;
    }
    return $ret;
}
示例#3
0
/**
 *	Fetch the remote repository, if this hasn't been done recently, and checkout the remote master branch
 *	@param $cache_key cache key
 *	@param $force force a fetch
 *	@return true if succesful, false if not
 */
function repo_check_for_update($cache_key, $force = false)
{
    $mtime = @filemtime(cache_dir($cache_key));
    if ($mtime === false) {
        return false;
    }
    if (!$force && time() - $mtime < config('repo_cache_time')) {
        // current version is recent enough
        return true;
    }
    $old_cwd = getcwd();
    $old_umask = @umask(00);
    // update file modification time for LRU
    @touch(cache_dir($cache_key));
    @chdir(cache_dir($cache_key));
    @exec('git fetch --all 2>&1', $out, $ret_val);
    if ($ret_val === 0) {
        @exec('git reset --hard origin/master 2>&1', $out, $ret_val);
    }
    @umask($old_umask);
    @chdir($old_cwd);
    return $ret_val === 0;
}