From 5841cb70662dcc9d8214f4ea3b4ebf6cdf32f23d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 24 Aug 2012 12:37:16 -0400 Subject: [PATCH] cc-3936: Made it so that identifer file is written before the file itself so that media monitor always has the identifier file before the song itself. --- airtime_mvc/application/models/StoredFile.php | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 87841be30..7a53b3ab2 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -918,22 +918,6 @@ class Application_Model_StoredFile // Did all the checks for realz, now trying to copy $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName); - Logging::info("copyFileToStor: moving file $audio_file to $audio_stor"); - // Martin K.: changed to rename: Much less load + quicker since this is - // an atomic operation - 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 - return array( - "code" => 108, - "message" => " - The file was not uploaded, this error can occur if the computer - hard drive does not have enough disk space or the stor - directory does not have correct write permissions."); - } - // Now that we successfully added this file, we will add another tag - // file that will identify the user that owns it $uid = Application_Model_User::getCurrentUser()->getId(); $id_file = "$audio_stor.identifier"; if (file_put_contents($id_file,$uid) === false) { @@ -945,6 +929,23 @@ class Application_Model_StoredFile Logging::info("Successfully written identification file for uploaded '$audio_stor'"); } + Logging::info("copyFileToStor: moving file $audio_file to $audio_stor"); + // Martin K.: changed to rename: Much less load + quicker since this is + // an atomic operation + 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 + return array( + "code" => 108, + "message" => " + The file was not uploaded, this error can occur if the computer + hard drive does not have enough disk space or the stor + directory does not have correct write permissions."); + } + // Now that we successfully added this file, we will add another tag + // file that will identify the user that owns it return null; }