Index: infusionBuilder-secure/php/postProcessor.php =================================================================== --- infusionBuilder-secure/php/postProcessor.php (revision 8998) +++ infusionBuilder-secure/php/postProcessor.php (working copy) @@ -128,7 +128,7 @@ * @return object $cache_row A row of data from the cache table if successful, FALSE otherwise */ function checkCacheMysql($cacheKey, $intMin, $error_message) { - $cache_query = "SELECT * FROM cache WHERE id = '{$cacheKey}' AND minified = ".$intMin; + $cache_query = "SELECT * FROM cache WHERE id = '{$cacheKey}' AND minified = ".$intMin; $cache_result = mysql_query($cache_query); if (!$cache_result) { //mysql_query resulted in error returnError($error_message); @@ -144,6 +144,33 @@ return $is_cached; } +/** + * Deletes a directory, including containing files and subdirectories. + * **I am having some problems with this function on windows due to the + * limitation that directory and file names are limited to 260 characters + * including path information. Because the depth of some of the infusion + * directories are so deep, some of my temp files are not being deleted. + * This needs more testing in a unix environment. + * + * @param $dir String name of the directory to be deleted. + * @return Boolean true if the deletion was successful and false otherwise + */ +function deleteDirectory($dir) { + if (!file_exists($dir)) return true; + if (!is_dir($dir)) { + return unlink($dir); + } + foreach (scandir($dir) as $item) { + if ($item == '.' || $item == '..') { + continue; + } + if (!deleteDirectory($dir."/".$item, $fh)) { + return false; + } + } + return rmdir($dir); +} + //START OF EXECUTION //process posted values @@ -188,6 +215,7 @@ $uuid = $uuid_row["uuid()"]; //initialize some variables +$tmpbuildpath = OUTPUT_FILE_PATH_BUILD.$uuid; //path for temporary build files $tmppath = OUTPUT_FILE_PATH_PRODUCTS.$uuid; //path for temporary files $cachepath = CACHE_FILE_PATH.$cacheKey; //path to cached files @@ -227,8 +255,13 @@ returnError("Cannot copy temp file to cache"); exit(1); } - - //insert cache entry for this build + + //delete the tmp files and remove directories + //$tmpbuildpath and $tmppath + deleteDirectory($tmppath); + deleteDirectory($tmpbuildpath); + + //insert cache entry for this build $insert_query = "INSERT INTO cache (id, minified) VALUES('$cacheKey', ".$intMin.")"; $insert_result = mysql_query($insert_query); if (!$insert_result) {