From d1b28fd5643f338202bb8e59313b2397230f33ce Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Tue, 24 Mar 2015 14:56:03 -0400 Subject: [PATCH] Fixed a bug in FTP upload hook, other minor improvements * Ensure we have write permissions on any newly uploaded files by FTP * Don't silence warnings in moveFileToStor() * Reduced the FTP upload max retry count * Log E_NOTICE and E_WARNING levels to Sentry --- airtime_mvc/application/logging/Logging.php | 2 ++ airtime_mvc/application/models/StoredFile.php | 3 +-- .../modules/rest/controllers/MediaController.php | 1 + python_apps/airtime_analyzer/tools/ftp-upload-hook.sh | 6 +++++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/logging/Logging.php b/airtime_mvc/application/logging/Logging.php index 5aef4baba..d6d30e932 100644 --- a/airtime_mvc/application/logging/Logging.php +++ b/airtime_mvc/application/logging/Logging.php @@ -138,7 +138,9 @@ class Logging { switch($err['type']) { case E_ERROR: + case E_WARNING: case E_PARSE: + case E_NOTICE: case E_CORE_ERROR: case E_CORE_WARNING: case E_COMPILE_ERROR: diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 5e6e53161..e73d0a246 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -986,13 +986,12 @@ SQL; // Martin K.: changed to rename: Much less load + quicker since this is // an atomic operation - if (@rename($audio_file, $audio_stor) === false) { + if (rename($audio_file, $audio_stor) === false) { //something went wrong likely there wasn't enough space in . //the audio_stor to move the file too warn the user that . //the file wasn't uploaded and they should check if there . //is enough disk space . unlink($audio_file); //remove the file after failed rename - //unlink($id_file); // Also remove the identifier file throw new Exception("The file was not uploaded, this error can occur if the computer " . "hard drive does not have enough disk space or the stor " diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 6a2cccd63..b43bac3c0 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -124,6 +124,7 @@ class Rest_MediaController extends Zend_Rest_Controller catch (Exception $e) { $this->unknownErrorResponse(); Logging::error($e->getMessage()); + throw $e; } } diff --git a/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh b/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh index aa543f853..4304f7594 100755 --- a/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh +++ b/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh @@ -2,10 +2,14 @@ post_file() { #kill process after 30 minutes (360*5=30 minutes) - max_retry=360 + max_retry=5 retry_count=0 file_path="${1}" + # Give us write permissions on the file to prevent problems if the user + # uploads a read-only file. + chmod +w "${file_path}" + #We must remove commas because CURL can't upload files with commas in the name # http://curl.haxx.se/mail/archive-2009-07/0029.html stripped_file_path=${file_path//','/''}