From 6e755b000b859baf178146dbad17098e3acd5d38 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 24 Apr 2012 16:15:22 -0400 Subject: [PATCH] CC-3707: copy files to stor, extra forwardslash -fixed --- airtime_mvc/application/common/OsPath.php | 21 +++++++++++++++++++ airtime_mvc/application/models/StoredFile.php | 3 +-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/common/OsPath.php b/airtime_mvc/application/common/OsPath.php index 47161301d..957545dc4 100644 --- a/airtime_mvc/application/common/OsPath.php +++ b/airtime_mvc/application/common/OsPath.php @@ -42,4 +42,25 @@ class Application_Common_OsPath{ else return '.'; } + + /* Similar to the os.path.join python method + * http://stackoverflow.com/a/1782990/276949 */ + function join() { + $args = func_get_args(); + $paths = array(); + + foreach($args as $arg) { + $paths = array_merge($paths, (array)$arg); + } + + foreach($paths as &$path) { + $path = trim($path, DIRECTORY_SEPARATOR); + } + + if (substr($args[0], 0, 1) == DIRECTORY_SEPARATOR) { + $paths[0] = DIRECTORY_SEPARATOR . $paths[0]; + } + + return join(DIRECTORY_SEPARATOR, $paths); + } } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 06e788095..fcac1a8db 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -841,8 +841,7 @@ Logging::log("getting media! - 2"); //check to see if there is enough space in $stor to continue. $enough_space = Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file); if ($enough_space){ - $stor .= "/organize"; - $audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName; + $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName); Logging::log("copyFileToStor: moving file $audio_file to $audio_stor"); //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation