From a9d288385b636a4e20526fbe6a5ffa0eaa395c43 Mon Sep 17 00:00:00 2001 From: Naomi Date: Tue, 29 Mar 2011 19:36:36 -0400 Subject: [PATCH] CC-2129 : Retry automatic upload to Soundcloud if Internet connection problem static retries/wait time right now. --- application/controllers/ApiController.php | 22 ++++++++++++++++++---- application/models/Soundcloud.php | 22 ++++++---------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/application/controllers/ApiController.php b/application/controllers/ApiController.php index 4f5f4eae3..9a8d45a01 100644 --- a/application/controllers/ApiController.php +++ b/application/controllers/ApiController.php @@ -268,11 +268,25 @@ class ApiController extends Zend_Controller_Action if(Application_Model_Preference::GetDoSoundCloudUpload()) { - $show = new Show($show_inst->getShowId()); - $description = $show->getDescription(); + for($i=0; $i<3; $i++) { - $soundcloud = new ATSoundcloud(); - $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description); + $show = new Show($show_inst->getShowId()); + $description = $show->getDescription(); + + try { + $soundcloud = new ATSoundcloud(); + $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description); + break; + } + catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { + $code = $e->getHttpCode(); + if($code != 0) { + break; + } + } + + sleep(60); + } } $this->view->id = $file->getId(); diff --git a/application/models/Soundcloud.php b/application/models/Soundcloud.php index 78e9223a5..1fc5efa99 100644 --- a/application/models/Soundcloud.php +++ b/application/models/Soundcloud.php @@ -48,22 +48,12 @@ class ATSoundcloud { 'track[description]' => $description ); - try { - $response = json_decode( - $this->_soundcloud->post('tracks', $track_data), - true - ); - - echo var_dump($response); - } - catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { - echo $e->getMessage(); - } - } - else - { - echo "could not get soundcloud token"; - } + + $response = json_decode( + $this->_soundcloud->post('tracks', $track_data), + true + ); + } } }