Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix zero-sized files (and some warnings) #252

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 1 addition & 50 deletions application/controllers/private/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,6 @@ function copy_project_files()
{
$file_name = $this->_copy_file($local_file, $copy_to_dir);
}
else
{
$file_name = $this->_get_file($section->listen_url, $copy_to_dir);
}

if (!$file_name) continue;

Expand All @@ -328,7 +324,7 @@ function copy_project_files()
$this->librivox_id3tag->_update_section($section->id, array('file_name' => $file_name, 'playtime' => $playtime));
}

$this->ajax_output(array('message' => 'Files copied.', 'tags' => $tag_data, 'full_tags' => $fullid3_tags), TRUE);
$this->ajax_output(array('message' => 'Files copied.'), TRUE);
}

function get_file_tags()
Expand Down Expand Up @@ -528,38 +524,6 @@ function _copy_file($local_file, $copy_to_dir)
return ($copied) ? $file_name : false;
}

function _get_file($file_url, $copy_to_dir)
{
set_time_limit(0);

$file_name = $this->_get_file_name_from_url($file_url);

$fp = fopen($copy_to_dir . '/' . $file_name, 'w');

$ch = curl_init($file_url);

curl_setopt_array($ch, array(
CURLOPT_URL => $file_url,
CURLOPT_RETURNTRANSFER => 1,
//CURLOPT_FILE => $fp,
CURLOPT_TIMEOUT => 50

));

$results = curl_exec($ch);
if (curl_errno($ch))
{
return false;
}

curl_close($ch);

fwrite($fp, $results); //old style, let me debug something. TODO: update
fclose($fp);

return $file_name;
}

function _get_file_name_from_url($url)
{
$query_marker = strpos($url, '?');
Expand Down Expand Up @@ -851,15 +815,6 @@ function test_copy_file()
echo $copied;
}

function test_copy_remote_file()
{
$listen_url = 'http://upload.librivox.org/share/uploads/rg/aristopia_00_holford.mp3';
$listen_url = 'https://librivox.local/librivox-validator-books/the_secret_garden_1308/aristopia_00_holford.mp3';
$copy_to_dir = 'C:/test_files/';

$this->_get_file($listen_url, $copy_to_dir);
}

function test_get_file()
{
//echo 'TEST';
Expand Down Expand Up @@ -897,10 +852,6 @@ function test_get_file()
{
$file_name = $this->_copy_file($local_file, $copy_to_dir);
}
else
{
$file_name = $this->_get_file($section->listen_url, $copy_to_dir);
}

if (!$file_name)
{
Expand Down