CC-5821: Airtime Analyzer: Ftp-uploaded folder doesn't get removed from organize

$_FILES does not store the original file path so we were losing the folder name.
Fixed by explicitly passing the full filepath in via the ftp-upload-hook.sh script
This commit is contained in:
drigato 2014-04-28 14:44:52 -04:00
parent d081ff10b2
commit fae5b15a9f
2 changed files with 16 additions and 7 deletions

View file

@ -136,6 +136,18 @@ class Rest_MediaController extends Zend_Rest_Controller
$file->save();
return;
} else {
/* If full_path is set, the post request came from ftp.
* Users are allowed to upload folders via ftp. If this is the case
* we need to include the folder name with the file name, otherwise
* files won't get removed from the organize folder.
*/
if (isset($whiteList["full_path"])) {
$fullPath = $whiteList["full_path"];
$basePath = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."/srv/airtime/stor/organize/" : "/srv/airtime/stor/organize/";
$relativePath = substr($fullPath, strlen($basePath));
} else {
$relativePath = $_FILES["file"]["name"];
}
$file->fromArray($whiteList);
$file->setDbOwnerId($this->getOwnerId());
@ -147,7 +159,7 @@ class Rest_MediaController extends Zend_Rest_Controller
$callbackUrl = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getRequestUri() . "/" . $file->getPrimaryKey();
$this->processUploadedFile($callbackUrl, $_FILES["file"]["name"], $this->getOwnerId());
$this->processUploadedFile($callbackUrl, $relativePath, $this->getOwnerId());
$this->getResponse()
->setHttpResponseCode(201)
@ -366,9 +378,6 @@ class Rest_MediaController extends Zend_Rest_Controller
return;
}
Logging::info($newTempFilePath);
//Logging::info("Old temp file path: " . $tempFilePath);
//Dispatch a message to airtime_analyzer through RabbitMQ,
//notifying it that there's a new upload to process!
Application_Model_RabbitMq::SendMessageToAnalyzer($newTempFilePath,

View file

@ -28,7 +28,7 @@ post_file() {
api_key=$(awk -F "= " '/api_key/ {print $2}' $instance_conf_path)
until curl --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}" -F "name=${filename}"
until curl --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}" -F "full_path=${file_path}"
do
retry_count=$[$retry_count+1]
if [ $retry_count -ge $max_retry ]; then