Skip to content

Commit

Permalink
Validator: Fix zero-size files (no curl fetches!)
Browse files Browse the repository at this point in the history
Fixes LibriVox#119, by removing the Validator code that would fetch MP3 files
from remote servers.  This was useful before Uploader became prevalent,
but we no longer need the feature now.
  • Loading branch information
redrun45 committed Jan 7, 2025
1 parent 972f8f8 commit e51f90f
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 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 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

0 comments on commit e51f90f

Please sign in to comment.