CC-3928: Use liquidsoap to test whether file is playable on upload.

-done
This commit is contained in:
denise 2012-06-04 17:01:43 -04:00
parent a3754be31a
commit 74e9f70506
1 changed files with 15 additions and 8 deletions

View File

@ -856,7 +856,6 @@ Logging::log("getting media! - 2");
$md5 = md5_file($audio_file);
$duplicate = Application_Model_StoredFile::RecallByMd5($md5, true);
$result = null;
if ($duplicate) {
if (file_exists($duplicate->getFilePath())) {
@ -886,6 +885,13 @@ Logging::log("getting media! - 2");
Logging::log("Warning: couldn't change permissions of $audio_file to 0644");
}
// Check if file is playable
$command = sprintf("/usr/bin/airtime-liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))' > /dev/null 2>&1", $audio_file);
exec($command, $output, $rv);
if ($rv != 0) {
$result = array("code" => 110, "message" => "This file appears to be corrupted and could not be uploaded.");
}
else {
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
$r = @rename($audio_file, $audio_stor);
@ -897,6 +903,7 @@ Logging::log("getting media! - 2");
}
}
}
}
return $result;
}