CC-3707: copy files to stor, extra forwardslash

-fixed
This commit is contained in:
Martin Konecny 2012-04-24 16:15:22 -04:00
parent 3c4d01aa93
commit 6e755b000b
2 changed files with 22 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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