Skip to content

Commit

Permalink
Improved cURL "file not found" handler & support for Github Organisat…
Browse files Browse the repository at this point in the history
…ions

Fix issue #9
  • Loading branch information
Wanchai committed Mar 17, 2016
1 parent 9a79031 commit 3b62611
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 1 addition & 3 deletions ftpbucket/BBjson.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ function load_files($br)
{
$dirname = dirname($file['file']);

$chdir = is_dir($wrapper.$dirname);

if (!$chdir)
if (!is_dir($wrapper.$dirname))
{
if (mkdir($wrapper.$dirname, 0705, true)) {
$this->log_it('Created new directory '.$dirname);
Expand Down
13 changes: 7 additions & 6 deletions ftpbucket/GHjson.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ function load_files($br)
{
$dirname = dirname($file);

$chdir = is_dir($wrapper.$dirname);

if (!$chdir)
if (!is_dir($wrapper.$dirname))
{
if (mkdir($wrapper.$dirname, 0705, true)) {
$this->log_it('Created new directory '.$dirname);
Expand All @@ -93,7 +91,7 @@ function load_files($br)
}
}

$url = 'https://raw.githubusercontent.com/'.$this->data->auth['username'].'/'.$this->data->ftp['repo_name'].'/'.$node.'/'.$file;
$url = 'https://raw.githubusercontent.com/'.$this->data->ftp["full_name"].'/'.$node.'/'.$file;

$cu = curl_init($url);
curl_setopt($cu, CURLOPT_USERPWD, $this->data->auth['username'].':'.$this->data->auth['password']);
Expand All @@ -103,9 +101,9 @@ function load_files($br)
$data = curl_exec($cu);

if (!$data)
{
$this->log_it('Cant\'t get the file '.$file.' cURL error: '.curl_error($cu));
}
else if (curl_getinfo($cu, CURLINFO_HTTP_CODE) == 404)
$this->log_it('Cant\'t get the file '.$file.' : 404');
else
{
if (file_put_contents($wrapper.$file, $data, 0, stream_context_create(array('ftp' => array('overwrite' => true)))))
Expand Down Expand Up @@ -151,6 +149,9 @@ function load_datas()
} else {
$this->log_it('Received a push from {'.$pl_repo_name.'}');
}

$this->data->ftp["full_name"] = $this->payload['repository']['full_name'];

// --- Required for Authentication --- //
$this->data->auth = $config['github'];

Expand Down

0 comments on commit 3b62611

Please sign in to comment.