Skip to content

Instantly share code, notes, and snippets.

@marinaglancy
Created August 1, 2012 02:55
Show Gist options
  • Save marinaglancy/3223172 to your computer and use it in GitHub Desktop.
Save marinaglancy/3223172 to your computer and use it in GitHub Desktop.
repository_github fix to test download error on moodle.org
diff --git a/lib.php b/lib.php
index ca85b5f..8e1f0ed 100644
--- a/lib.php
+++ b/lib.php
@@ -257,14 +257,12 @@ class repository_github extends repository {
$fp = fopen($path, 'w');
$c = new curl();
- $c->setopt(array('CURLOPT_FOLLOWLOCATION' => true, 'CURLOPT_MAXREDIRS' => 3));
- $result = $c->download(array(array('url' => $url, 'file'=> $fp)));
-
- // Close file handler.
+ $result = $c->get($url, array(), array('file'=> $fp, 'followlocation' => true));
fclose($fp);
- if (empty($result)) {
+ if ($result !== true) {
unlink($path);
- return null;
+ throw new moodle_exception('repositoryerror', 'repository', '',
+ str_replace("\n", "<br>\n", $result."\n".print_r($c->get_info(), true))); // TODO this is temporary for debugging!
}
return array('path'=>$path, 'url'=>$url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment